1. 程式人生 > >Expected MultipartHttpServletRequest: is a MultipartResolver configured?

Expected MultipartHttpServletRequest: is a MultipartResolver configured?

XML red commons param 方法 ng- rop dsi ring

解決方法: (1) 第一步:引入commons-fileupload-1.2.jar,具體版本號以具體項目要求為準; 第二步:在spring-mvc.xml中增加如下配置,具體文體大小限制以具體項目要求為準
<!-- 設置上傳文件最大值   1M=1*1024*1024(B)=1048576 bytes -->    
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">    
    <property name="maxUploadSize" value="1048576" />    
</bean>

(2)

我是在Controller中的方法加了@RequestParam("file")Mutipart file,但是我spring.xml中引用的是自定義的包,不是spring本體的包,所以報錯了

Expected MultipartHttpServletRequest: is a MultipartResolver configured?