Content type 'multipart/form-data;boundary=----WebKitFormBoundaryTbH6ceTSIdKXWyla;charset=UTF-8' not supported
时间: 2023-12-21 20:05:29 浏览: 191
http post上传文件与表格 ContentType = multipart/form-data
Content type 'multipart/form-data;boundary=--------------------------036764477110441760467042;charset=UTF-8' not supported错误是指请求的Content-Type类型不被支持。将这个错误信息翻译成中文是指不支持'multipart/form-data;boundary=--------------------------036764477110441760467042;charset=UTF-8'请求类型。
解决这个问题的方法是使用@RequestParam注解替换掉@RequestBody注解。具体示例代码如下:
```java
@ApiOperationSupport(author = "念兮为美")
@ApiOperation(value = "文件上传")
@PostMapping("/upload")
@LogAnnotation
public ReturnResult upload(
@RequestHeader(value = REQUEST_HEADER_TOKEN) String token,
@RequestParam("file") MultipartFile file,
@RequestParam("fileType") String fileType
) {
TokenProperties tokenProperties = jwtTokenProvider.parseToken(token);
UploadDto uploadDto = new UploadDto(file, fileType);
ReturnResult upload = fileService.upload(uploadDto, tokenProperties);
return upload;
}
```
阅读全文