Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
[SPR-10591] Spring's support for javax.servlet.http.Part vs. MultipartFile incomplete, inconsistent Created: 27/May/13 Updated: 26/Jan/16 Resolved: 02/Oct/13 Status: Project: Component/s: Affects Version/s: Fix Version/s: Closed Spring Framework Web 3.1 GA, 3.2 GA, 4.0 M1 Type: Reporter: Resolution: Labels: Remaining Estimate: Time Spent: Original Estimate: Bug Nick Williams Complete None Not Specified Issue Links: Relate is related to SPR-13893 Part list/array gets resolved to all ... is related to SPR-11353 @RequestPart(...) MultipartFile[] doe... is related to SPR-13849 MultipartFile argument requires multi... 4.0 RC1 Priority: Assignee: Votes: Major Rossen Stoyanchev 0 Not Specified Not Specified Closed Closed Closed 3 years, 36 weeks, 1 day ago Days since last comment: Last commented false by a User: Juergen Hoeller Last updater: Description Spring's support for javax.servlet.http.Part vs. org.springframework.web.multipart.MultipartFile should be the case. I'm using @Configuration with @EnableWebMVC. I define the following bean in my configuration: @Bean public MultipartResolver multipartResolver() { return new StandardServletMultipartResolver(); } The following eight scenarios demonstrate the inconsistencies. It seems to me that all eight scenarios should wor Scenario 1 I have a controller handler method with a @RequestPart MultipartFile parameter. Everything works fine, and Scenario 2 I have a controller handler method with a @RequestPart List<MultipartFile> parameter. Everything works f single file and multiple files; both worked). Scenario 3 I have a controller handler method with a @RequestPart Part parameter. Everything works fine, and when the m Scenario 4 I have a controller handler method with a @RequestPart List<Part> parameter. I tired uploading a single file a this request because the request entity is in a format not supported by the requested resource for the requested m 13:17:07.352 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServ processing POST request for [/support/ticket/create] 13:17:07.376 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa handler method for path /ticket/create 13:17:07.376 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa method [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w throws java.io.IOException] 13:17:07.376 [http-nio-8080-exec-3] DEBUG org.springframework.beans.factor org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Ab bean 'ticketController' 13:17:07.561 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotSuppo 13:17:07.565 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotSuppo 13:17:07.566 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w throws java.io.IOException]: org.springframework.web.HttpMediaTypeNotSuppo 13:17:07.567 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.processDispatchResult(Di DispatcherServlet with name 'springDispatcher': assuming HandlerAdapter co 13:17:07.567 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkS Scenario 5 I have a controller handler method with a Form command-object parameter. The Form (POJO) has a field in it of the method. Scenario 6 I have a controller handler method with a Form command-object parameter. The Form has a field in it of type Lis supplied to the method (I tired uploading a single file and multiple files; both worked). Scenario 7 I have a controller handler method with a Form command-object parameter. The Form (POJO) has a field in it of client was syntactically incorrect." The following debug information appeared in the log for this request: 13:37:27.657 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServ processing POST request for [/support/ticket/create] 13:37:27.685 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa handler method for path /ticket/create 13:37:27.686 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa method [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w 13:37:27.686 [http-nio-8080-exec-4] DEBUG org.springframework.beans.factor org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Ab bean 'ticketController' 13:37:27.690 [http-nio-8080-exec-4] DEBUG org.springframework.beans.BeanUt org.springframework.beans.BeanUtils.findEditorByConvention(BeanUtils.java: javax.servlet.http.Part according to 'Editor' suffix convention 13:37:27.693 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.javax [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments'; nested exception is java.lang.IllegalStateExce [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments': no matching editors or conversion strategy fou 13:37:27.696 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.javax [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments'; nested exception is java.lang.IllegalStateExce [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments': no matching editors or conversion strategy fou 13:37:27.696 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.javax [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments'; nested exception is java.lang.IllegalStateExce [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments': no matching editors or conversion strategy fou 13:37:27.700 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.processDispatchResult(Di DispatcherServlet with name 'springDispatcher': assuming HandlerAdapter co 13:37:27.701 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkS Scenario 7 I have a controller handler method with a Form command-object parameter. The Form (POJO) has a field in it of request with error code 400: "The request sent by the client was syntactically incorrect." The following debug in 13:39:27.414 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServ processing POST request for [/support/ticket/create] 13:39:27.443 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa handler method for path /ticket/create 13:39:27.447 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHa method [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w 13:39:27.448 [http-nio-8080-exec-1] DEBUG org.springframework.beans.factor org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Ab bean 'ticketController' 13:39:27.488 [http-nio-8080-exec-1] DEBUG org.springframework.beans.BeanUt org.springframework.beans.BeanUtils.findEditorByConvention(BeanUtils.java: javax.servlet.http.Part according to 'Editor' suffix convention 13:39:27.491 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.java. [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq property 'attachments'; nested exception is java.lang.IllegalStateExceptio [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments[0]': no matching editors or conversion strategy 13:39:27.494 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.java. [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq property 'attachments'; nested exception is java.lang.IllegalStateExceptio [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments[0]': no matching editors or conversion strategy 13:39:27.494 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.r exception from handler [public org.springframework.web.servlet.View com.wrox.site.TicketController.create(javax.servlet.http.HttpSession,com.w org.springframework.validation.BindException: org.springframework.validati Field error in object 'form' on field 'attachments': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletReq [typeMismatch.form.attachments,typeMismatch.attachments,typeMismatch.java. [org.springframework.context.support.DefaultMessageSourceResolvable: codes [attachments]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletReq property 'attachments'; nested exception is java.lang.IllegalStateExceptio [org.springframework.web.multipart.support.StandardMultipartHttpServletReq for property 'attachments[0]': no matching editors or conversion strategy 13:39:27.495 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.DispatcherServlet.processDispatchResult(Di DispatcherServlet with name 'springDispatcher': assuming HandlerAdapter co 13:39:27.496 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkS Comments Comment by Brian Clozel [ 02/Oct/13 ] a PR has been submitted; this should fix the last two scenarii listed in this issue. Comment by Rossen Stoyanchev [ 02/Oct/13 ] All scenarios should now work. Generated at Thu Jun 08 14:28:27 UTC 2017 using JIRA 6.4.14#64029sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.