spring mvc 多文件上传时报错MultipartHttpServletRequest 10
org.apache.catalina.connector.RequestFacadecannotbecasttoorg.springframework.web.mult...
org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest
at cn.com.abc.web.controller.member.Test.add(Controller.java:86)
已经有commons-fileupload-1.2.1.jar和commons-io-1.4.jarb包了,
而且在web.xml文件中添加了下面代码,还是报错,
<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>
</bean> 展开
at cn.com.abc.web.controller.member.Test.add(Controller.java:86)
已经有commons-fileupload-1.2.1.jar和commons-io-1.4.jarb包了,
而且在web.xml文件中添加了下面代码,还是报错,
<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>
</bean> 展开
3个回答
展开全部
1、确认<form name="contractForm" id="contractForm" action="" method="post" enctype ="multipart/form-data">;
2、确认commons-fileupload.jar 和 org.springframework.web.jar 存在环境
3、MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
这一句会报错:ApplicationHttpRequest cannot be cast to MultipartHttpServletRequest
解决办法是通过这种方式:
MultipartResolver resolver = new CommonsMultipartResolver(request.getSession().getServletContext());
MultipartHttpServletRequest multipartRequest = resolver.resolveMultipart(request);
2、确认commons-fileupload.jar 和 org.springframework.web.jar 存在环境
3、MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
这一句会报错:ApplicationHttpRequest cannot be cast to MultipartHttpServletRequest
解决办法是通过这种方式:
MultipartResolver resolver = new CommonsMultipartResolver(request.getSession().getServletContext());
MultipartHttpServletRequest multipartRequest = resolver.resolveMultipart(request);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询