Struts 1.x has inbuilt mechanisms to handle multi part posts (file uploads). By default it uses Apache Commons Fileupload. In the application I was working on we used Struts as the MVC framework, but Spring to do pretty much everything else. Springs, Struts integration module was extensively used, and we were using Spring’s SpringBindingActionForm for almost all action form handling. On the same lines, we wanted to use Spring’s Multipart file support (MultipartFile).
Unfortunately, by the time request would reach Spring’s ServletRequestDataBinder, Commons Fileupload would have already handled the multi part request and wrapped it. And there was no available documentation on the Struts website to disable this feature. A little bit of hacking struts code did reveal a pretty easy solution, just disable multipart handling in the init parameters of the struts servlet in the web.xml of your application:
<!-- Struts Action <span class="hiddenSpellError" pre="Action ">Servlet</span> --> <servlet> <servlet-name>ach-action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> The Struts Config File <param-name>config</param-name> /WEB-INF/config/struts-config.xml </init-param> <!-- The following parameter disables multi part handling by struts --> <init-param> <description>Disable Struts Multipart Handling</description> <param-name>multipartClass</param-name> <param-value>none</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
This has been tested on Struts 1.3.8, but should work on other 1.x versions too.