我是靠谱客的博主 追寻樱桃,这篇文章主要介绍Spring-boot: StandardMultipartFile不能转换为CommonsMultipartFile的问题,现在分享给大家,希望可以做个参考。

异常信息:

.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配置文件中加上

  servlet:
    multipart:
      enabled: true

2、把SpringMvc使用的 @RequestParam CommonsMultiPartFile 替换为 @RequestParam MultipartFile file,如下图

即可处理此bug,如下加上其他配置限制上传的信息,可在multipart中新增接口

最后

以上就是追寻樱桃最近收集整理的关于Spring-boot: StandardMultipartFile不能转换为CommonsMultipartFile的问题的全部内容,更多相关Spring-boot:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(95)

评论列表共有 0 条评论

立即
投稿
返回
顶部