spring mvc 多文件上传时报错MultipartHttpServletRequest
1个回答
展开全部
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);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询