问题
上传图片时报错:
Content type ‘multipart/form-data;boundary=----WebKitFormBoundarypOpfYxCGU6Q4sciA;charset=UTF-8’ not supported
Controller层:
@PostMapping(path = "/uploadRotationImg")
public ResponseEntity<String> uploadRotationImg(@RequestParam("photos") MultipartFile file, @RequestBody ImgRotation imgRotation) {
try {
// 进行上传操作
return imgRotationService.uploadRotationImg(file, imgRotation);
} catch (Exception e) {
// 上传失败
e.printStackTrace();
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
解决
去掉@RequestBody
注解就行了
@PostMapping(path = "/uploadRotationImg")
public ResponseEntity<String> uploadRotationImg(@RequestParam("photos") MultipartFile file, ImgRotation imgRotation) {
try {
// 进行上传操作
return imgRotationService.uploadRotationImg(file, imgRotation);
} catch (Exception e) {
// 上传失败
e.printStackTrace();
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}