【发布时间】:2020-01-21 08:46:46
【问题描述】:
我想接收带有请求正文数据的多部分图像文件,但无法弄清楚,为什么会抛出 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported 异常
下面是我的实现
public ResponseEntity<GlobalResponse> createUser(@Valid @RequestPart("json") UserDTO userDTO ,@RequestPart(value ="file", required=false)MultipartFile file) throws IOException {
//Calling some service
return new ResponseEntity<>( HttpStatus.OK);
}
编辑: 这是我的邮递员配置
【问题讨论】:
-
不工作是什么意思?它会引发任何错误吗?请详细说明
-
请向我们展示您的客户端实现
-
@Mustahsan 它正在抛出 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported exception
-
可以分享一下你在这个方法上面使用的RequestMapping配置吗?
-
@ValentynRiabukhin 现在,我正在使用 Postman 测试 API
标签: java spring-boot multipartform-data