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);

更多推荐

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