File upload Struts2 Portlet<;s:文件>;fileupload标记在提交后的操作中为null

File upload Struts2 Portlet<;s:文件>;fileupload标记在提交后的操作中为null,file-upload,struts2,portlet,File Upload,Struts2,Portlet,我正在使用struts2 JSR 286 portlet,必须实现文件上传功能 我在action类中使用fileupload struts2标记和等效的正确setter和getter方法 但是,在upload JSP中单击Submit按钮时,我无法在Action类中接收文件参数及其内容 有人能告诉我fileupload标记是否不支持struts2 portlet或在struts2 portlet中工作吗 我使用的是struts 2.3.20.3版本 下面是我的代码: 这是我的Struts2 Po

我正在使用struts2 JSR 286 portlet,必须实现文件上传功能

我在action类中使用fileupload struts2标记和等效的正确setter和getter方法

但是,在upload JSP中单击Submit按钮时,我无法在Action类中接收文件参数及其内容

有人能告诉我fileupload标记是否不支持struts2 portlet或在struts2 portlet中工作吗

我使用的是struts 2.3.20.3版本

下面是我的代码:

这是我的Struts2 Portlet

<portlet id="MyPortlet">
    <description xml:lang="EN">My Portlet</description>
    <portlet-name>MyPortlet</portlet-name>
    <display-name xml:lang="EN">my-portlet</display-name>

    <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
struts.xml:

<package name="default" extends="struts-portlet-default" namespace="/">
<action name="doUpload" class="com.example.UploadAction">    
<result name="success">upload_success.jsp</result>
</action>
</package>

上传_success.jsp

Hi@AndreaLigios-你能看看我在这里分享的代码吗?看起来不错。您可以尝试更改属性的名称以尊重它们的getter和setter吗?@AndreaLigios,更改了属性/字段名称没有更改。仅供参考,我的项目使用的是OpenPortal Portelt容器。您好@AndreaLigios-您能看看我在这里共享的代码吗?看起来不错。您可以尝试更改属性的名称以尊重其getter和setter吗?@AndreaLigios,更改了属性/字段名称,没有更改。仅供参考,我的项目正在使用OpenPortal Portelt容器。
 public class UploadAction extends ActionSupport {
  private File file;
  private String contentType;
  private String filename;

  public void setUpload(File file) {
     this.file = file;
  }

  public void setUploadContentType(String contentType) {
     this.contentType = contentType;
  }

  public void setUploadFileName(String filename) {
     this.filename = filename;
  }

  public String execute() {
     //...
     return SUCCESS;
  }
<package name="default" extends="struts-portlet-default" namespace="/">
<action name="doUpload" class="com.example.UploadAction">    
<result name="success">upload_success.jsp</result>
</action>
</package>