错误:org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘multipart/form-data

[org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘multipart/form-data;boundary=----WebKitFormBoundaryY9KyU12I9Bwqx2xp;charset=UTF-8’ not supported]

{
  "timestamp": "2020-08-02 19:28:02",
  "status": 415,
  "error": "Unsupported Media Type",
  "message": "",
  "path": "/admin/loopimage/addloopImage"
}

在这里插入图片描述

在上传文件的时候,spring框架会自动装配文件类型, 使用@RequestBody接收对象,所对应的content-type :application/json。所以当使用@RequestBody和文件上传的时候,会报错。

解决办法:去掉@RequestBody注解

猜你喜欢

转载自blog.csdn.net/qq_44895397/article/details/107796136
今日推荐