在做文件上传的时候遇到这个错误:
org.springframework.web.multipart.MultipartException:
接下来给出解决方法:
1.是否配置了
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
2. form是否设置了
<form id="fileupload" method="post" enctype="multipart/form-data">
3. 方法里
@RequestMapping(value = "/upload.do",headers = "content-type=multipart/*", method = RequestMethod.POST)
public String upload(@RequestParam(value = "file", required = false) MultipartFile file, MultipartHttpServletRequest request, ModelMap model) {
4. 依赖jar包
- commons-fileupload.jar
- commons-io.jar