问题
在使用element ui做前端开发时,用到了文件上传组件,但是控制台却爆出了 {“timestamp”:“2021-08-14T12:56:26.710+00:00”,“status”:500,“error”:“Internal Server Error”,“path”:"/member/photoUpload"} 的错误,随后查看服务器那边,并没有报错,但是有个警告,一开始还真么发现,找了好久。
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.CommonsMultipartResolver';
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.CommonsMultipartResolver':
no matching editors or conversion strategy found]
解决方案
发现就是类型转换不通过,将用来接收的文件上传类CommonsMultipartFile改为MultipartFile接口即可。不用CommonsMultipartFile这个实现类,而用org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile这个实现类。
|