Have a working Struts2 portlet environment where I cannot make Struts fileUpload work, in portlet mode.
I can see that
- A file is uploaded to the server, created in temp space.
- A multipart request is present on the original request, with the filename and file contents, where it enters Struts classes.
- I can trigger the maximum size response, the default value set in Struts.
- The FileUploadInterceptor is triggered but in the Jakarta MultipartRequest there is no file. Somewhere between the original request and the Jakarta wrapper the file is lost.
I have tried the same approach in a stripped down Spring boot 2 application, the same problem occurs as in the main project. Followed the code at
https://struts.apache.org/core-developers/file-upload.html
for the JSP and action classes. The portlet is created, the flow works, but no file in the action.
Standard Sping Boot 2 with extra in pom:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.5.20</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
Struts.xml
<package name="uploadtest" extends="struts-portlet-default" namespace="/uploadtest">
<action name="uploadtestPrepare" class="bouvet.no.fileuploadtest.action.FileUploadSubmitAction">
<result name="success">/WEB-INF/struts2/test/fileUpload.jsp</result>
</action>
<action name="uploadTestSubmit" class="bouvet.no.fileuploadtest.action.FileUploadSubmitAction">
<result name="success">/WEB-INF/struts2/test/fileUpload.jsp</result>
</action>
</package>
and the form
<s:form action="uploadTestSubmit" method="post" enctype="multipart/form-data">
FileName: <s:property value="%{filename}"/>
<s:file name="upload" label="File" />
<s:submit/>
</s:form>
a setter
public void setUploadFileName(String filename) {
this.filename = filename;
}
Is this a bug in portlet mode or am I missing a key dependency, a component, version? Alternative method?
In the image, a breakpoint in the JSR168 dispatcher, the file is present. First code to run after the server. breakpoint in JSR168 dispatcher