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);
spring mvc 多文件上传时报错MultipartHttpServletRequest
最新推荐文章于 2022-01-05 11:41:43 发布