获取
o.s.w.s.m.s.DefaultHandlerExceptionResolver.logException - Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=--------------------------917244744405307766670554;charset=UTF-8' not supported]
以下代码
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE,consumes =
MediaType.MULTIPART_FORM_DATA_VALUE,value = "/{userId}")
@Override
public ResponseEntity<WarrantyDetailsRequestResponse> createWarrantyDetails
(@RequestBody UsersWarrantyDetailsDTO usersWarrantyDetails,
@PathVariable("userId") Long userId,
@RequestParam("qrCodeImage") MultipartFile qrCodeImage,
@RequestParam("productInvoice") MultipartFile productInvoice,
@RequestParam("other_files") MultipartFile[] otherProductFiles) {
return new ResponseEntity<>(warrantyDetailsRequestResponse, HttpStatus.CREATED);
}
从 Postman 发送多部分表单数据请求,正确处理所有文件数据,但仍然是 Spring Boot 报告
Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=--------------------------917244744405307766670554;charset=UTF-8' not supported]
您必须从@PostMapping中删除消耗和生产 并将@RequestBody替换为@ModelAttribute。