java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?

來源:互聯網
上載者:User

標籤:

異常資訊:  2014-8-4 18:29:42 org.apache.catalina.core.StandardWrapperValve invoke

嚴重: Servlet.service() for servlet springServlet threw exception java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?   

at org.springframework.util.Assert.notNull(Assert.java:112)   

at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.resolveName(RequestParamMethodArgumentResolver.java:151)   

at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:86)    ...   

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)   

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)   

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)   

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)   

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)   

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)   

at java.lang.Thread.run(Thread.java:662)

 

解決方案:  

spring mvc中上傳附件,需要做兩步操作

1.引入包commons-fileupload-1.3.jar,版本號碼可以根據項目情況調整;  

2.在spring mvc設定檔中增加配置,檔案大小限制可根據項目情況調整:

<!-- 上傳檔案攔截,設定最大上傳檔案大小   10M=10*1024*1024(B)=10485760 bytes --> 

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

      <property name="maxUploadSize" value="10485760" /> 

</bean>

 

java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a MultipartResolver configured?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.