Content type 'multipart/form-data;boundary=---- ;charset=UTF-8' not support 异常

问题描述

调用微服务接口, 使用 Postman 提交表单格式的数据时, 返回 “Content type ‘multipart/form-data;boundary=---- ;charset=UTF-8’ not support” 错误

解决办法

一是服务接口的请求类型(Content-Type)指定为表单类型: consumes = MediaType.MULTIPART_FORM_DATA_VALUE

二是去掉 @RequestBody 注解

@PostMapping(value = "/form/submit", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
void uploadFile(MultipartFile file, HttpServletResponse response, HttpServletRequest request);
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐