原文异常
java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade
cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest
实现springMvc文件上传报如上错误:
问题出现的原因
1.在前端页面提交的表单中没有enctype="multipart/form-data"
属性,或者提交的方式不正确
2.在springMvc中没有开启文件上传拦截器
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- set the max upload size100MB -->
<property name="maxUploadSize">
<value>104857600</value>
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
<property name="defaultEncoding">
<value>utf-8</value>
</property>
</bean>