ARTICLE AD BOX
I am moving an ancient webapp from Spring 3 to Spring 6. I have just about everything else working, but am having to start from scratch with file upload and this is the only project I've ever worked on file upload.
I had this working controller under Spring 3 and have been modifying it. The form tag looks like this:
<form action="uploadFile" method="post" enctype="multipart/form-data" commandName="uploadCommand"> ... <input type="file" id="fileUpload" name="fileUploaded">And my controller:
@MultipartConfig public class UploadController extends AbstractController implements InitializingBean { protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { UploadForm cmd = new UploadForm(); String contentType = request.getContentType(); \_log.fatal("Content Type: {}", contentType); String viewName; if (contentType.startsWith(CONTENT_MULTIPART)) { Collection\<Part\> parts = request.getParts(); // added this line for debugging and it is now blowing up here. \_log.fatal("Parts: {}", parts); Part filePart = request.getPart(FILE_KEY); // was blowing up here. viewName = processFormSubmission(request, response, cmd, filePart); } else { ControllerHelper.populateForm(request.getReader(), cmd); viewName = showForm(request); } return new ModelAndView(viewName); }And here's the exception
java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided at org.apache.catalina.connector.Request.parseParts(Request.java:2473) \~\[catalina.jar:11.0.8\] at org.apache.catalina.connector.Request.getParts(Request.java:2441) \~\[catalina.jar:11.0.8\] at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:543) \~\[catalina.jar:11.0.8\] at com.gs.ejuror.web.controllers.UploadController.handleRequestInternal(UploadController.java:96) \~\[eJurorWeb-2.17.5.jar:2.17.5\] at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:178) \~\[spring-webmvc-6.2.7.jar:6.2.7\] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51) \~\[spring-webmvc-6.2.7.jar:6.2.7\] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089) \~\[spring-webmvc-6.2.7.jar:6.2.7\] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) \~\[spring-webmvc-6.2.7.jar:6.2.7\] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) \~\[spring-webmvc-6.2.7.jar:6.2.7\] ...Everything I read says this problem is caused by no @MultipartConfig, but, as you can see, it's there.
I also found this: Spring-Boot + Tomcat 8.0.3 FileUpload error Unable to process parts as no multi-part configuration has been provided but I'm not using Spring boot, so not sure how it applies.
