I'm migrating an application from Struts 2.5 to 7.0.3 and encountering
persistent issues with file upload functionality despite following the
documentation.

The UploadedFile object remains null in my action class, even with:

- Correct UploadedFilesAware implementation
- Proper multipart form configuration
- Debug logs showing no uploaded files (ActionFileUploadInterceptor reports
empty acceptedFiles)

Logs show:

2025-05-09 01:00:25 DEBUG ActionFileUploadInterceptor:179 - No files have
been uploaded/accepted
2025-05-09 01:00:25 WARN File:79 - Struts has detected a file upload UI tag
(s:file) being used without a form set to method 'POST'
(Despite <s:form method="POST" enctype="multipart/form-data"> being
correctly declared)

Basic action:
// Action
public class HelloAction extends ActionSupport implements
UploadedFilesAware {
    public UploadedFile upload; // Always null

   @Override
    public String execute() {
 //do something with the file
    return SUCCESS;
   }
    @Override
    public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
        if (!uploadedFiles.isEmpty()) {
             //This never execute cause always is empty
            this.upload = uploadedFiles.get(0); // Never reached
        }
    }
}
struts.xml:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 6.5//EN"
    "https://struts.apache.org/dtds/struts-6.5.dtd";>
<struts>
<constant name="struts.multipart.parser" value="jakarta" />
    <constant name="struts.multipart.maxSize" value="10485760" /> <!-- 10MB
-->
    <constant name="struts.multipart.saveDir" value="C:
temp"/> <!-- Ruta absoluta -->
      <package name="default" extends="struts-default">

      <action name=""><result>/hello.jsp</result></action>

        <action name="hello"
class="mx.com.jeser.ejemplo.actions.HelloAction">
            <interceptor-ref name="actionFileUpload" />
        <interceptor-ref name="basicStack" />
          <result name="success">/success.jsp</result>
          <result name="input">/input.jsp</result>
          <result name="error">/error.jsp</result>
        </action>
    </package></struts>

We are trying to implement the new features according the follow docs for
version 7.0.3:

https://struts.apache.org/security/#defining-and-annotating-your-action-parameters
https://struts.apache.org/core-developers/action-file-upload-interceptor

I would greatly appreciate your assistance in identifying if we might be
overlooking any undocumented requirements or configurations.

Reply via email to