异常信息
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile': no matching editors or conversion strategy found]
解决办法
1、在yml配置文件中加上:
2、把SpringMvc使用的 @RequestParam CommonsMultiPartFile 替换为 @RequestParam MultipartFile file
@RequestMapping("/uploadfile")
@ResponseBody
public void uploadfile(@RequestParam("file") MultipartFile file){
String fileName = file.getOriginalFilename();
}