What else do you use? Spring, Tomcat? It looks like something is changing the type of MultiPartRequestWrapper between Dispatcher and interceptors, mayb the request is wrapped with another proxy?
wt., 13 maj 2025 o 01:48 Zoran Avtarovski <zo...@sparecreative.com> napisaĆ(a): > > Hi Guys, > > We have started migrating our apps to 6.7.4 and have run into an issue > with file uploads. We have migrated our actions to use the new > ActionFileUploadInterceptor but we are seeing an issue where the upload > requests are being incorrectly bypassed. > > I have reduced it to a simple example which I will include at the end > but the key bits are the debug logs from struts. We are seeing the > request processed correctly, except for the last step where the upload > is bypassed: > > dispatcher.Dispatcher (Dispatcher.java:1054) - Support for multipart request > is enabled: true > dispatcher.Dispatcher (Dispatcher.java:1072) - Validating if this is a proper > Multipart request. Request is POST: true and ContentType matches pattern > (^multipart/form-data(?:\s*;\s*boundary=[0-9a-zA-Z'"()+_,\-./:=?]{1,70})?(?:\s*;\s*charset=[a-zA-Z\-0-9]{3,14})?): > true > dispatcher.Dispatcher (Dispatcher.java:1030) - Wrapping multipart request > with: MultiPartRequestWrapper > > multipart.JakartaMultiPartRequest (JakartaMultiPartRequest.java:105) - Found > file item: [document] > multipart.JakartaMultiPartRequest (JakartaMultiPartRequest.java:116) - Item > is a file upload > > interceptor.FileUploadInterceptor (FileUploadInterceptor.java:197) - > Bypassing /action/... > interceptor.ActionFileUploadInterceptor > (ActionFileUploadInterceptor.java:139) - Bypassing /action/... > > The struts dispatcher sees the request as being a valid Multipart POST > request and and wraps it with the MultipartRequestMapper. > The JakartaMultiPartRequest finds and recognises the uploaded file > parameter [document] > But then the two upload interceptors Bypass processing which means the > withUploadedFiles method on the action is not called. > > I had a look at the source for the ActionFileUploadInterceptor and the > request is only bypassed if it is not an instance of > MultipartRequestMapper, which according to the logs it is. I'm very > confused. I setup a simple test to prove we weren't going mad. > > Form is a simple form: > > <s:form action="saveStockItem" method="POST" > enctype="multipart/form-data"> > <s:hidden name="item.itemId"/> > <s:textfield name="item.name" key="stock.name"></s:textfield> > <s:textarea name="item.description" > key="stock.description"></s:textarea> > <s:file name="document" key="stock.image"></s:file> > <s:submit >upload</s:submit> > </s:form> > > The stack is the struts standard defaultStack from the core > struts-default.xml > > <action name="saveStockItem" class="stockAction" method="save"> > <interceptor-ref name="defaultStack"/> > <result name="input">/WEB-INF/pages/formStock.jsp</result> > <result name="success" type="redirectAction">stockItems</result> > </action> > > The action class implements UploadedFilesAware and has an appropriate > withUploadedFiles method. > > Has anyone experienced this or is it obvious what we are missing. Any > help would be appreciated. > > Zoran --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org