Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案

简介: Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案

一、现象描述

我是在使用PostMan发送请求时,出现了这个问题,后台报错信息如下:

org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=--------------------------570391279993820714772271;charset=UTF-8' not supported

 

二、问题原因

原因是我们的接口做了规范,默认就是通过@RequestBody 的方式请求的;也就是每一个请求必须是通过实体对象进行传参,不能通过form-data 表单提交的方式进行传参;

@PostMapping("/")
public RespBean addRole(@RequestBody  Role role){
    if (roleService.addRole(role) == 1) {
        return RespBean.ok("添加成功!");
    }
    return RespBean.error("添加失败!");
}

三、解决方案

1、改成json方式提交

2、把接口的@RequestBody 注解去掉

以上两种选择一种就可以了

 

完结!


相关文章
|
11月前
|
XML JSON 人工智能
Error while extracting response for type [class xxx] and content type application/xml;charset=UTF-8
Error while extracting response for type [class xxx] and content type application/xml;charset=UTF-8
612 0
|
2月前
|
JSON Java 数据格式
Could not extract response: no suitable HttpMessageConverter found for ..content type [text/html...]
Could not extract response: no suitable HttpMessageConverter found for ..content type [text/html...]
181 0
|
8月前
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
head 插件 Content-Type header [application/x-www-form-urlencoded] is not supported
80 1
|
9月前
|
JSON 数据格式
Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案
Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案
94 0
|
Java 测试技术
body-parser:unsupported content encoding 错误
最近遇到了一个奇怪的问题,关于body-parser报错,我本地调用没问题,使用测试工具没问题,这种方案都没问题,就和我对接的程序调用有问题,于是开始了面向百度编程,查到了两种解决方案:
445 0
body-parser:unsupported content encoding 错误
|
Java API 容器
理解HTTP协议中的multipart/form-data
之前在写一个通用HTTP组件的时候遇到过媒体(Media)类型multipart/form-data的封装问题,这篇文章主要简单介绍一下HTTP协议中媒体类型multipart/form-data的定义、应用和简单实现。
771 0
理解HTTP协议中的multipart/form-data
|
XML JSON 前端开发
Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
讲述ajax请求后端传参报 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported问题处理
 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
|
应用服务中间件 nginx Windows
1113: No mapping for the Unicode character exists in the target multi-byte code page
1113: No mapping for the Unicode character exists in the target multi-byte code page
254 0
1113: No mapping for the Unicode character exists in the target multi-byte code page
|
Java
java实战小结-Controller报错:Content type ‘multipart/form-data;boundary=----WebKitFormBoundaryxxxx not supp
java实战小结-Controller报错:Content type ‘multipart/form-data;boundary=----WebKitFormBoundaryxxxx not supp
337 0
|
JavaScript 前端开发
sendData to ABAP backend via multiple form content type
Created by Jerry Wang, last modified on Aug 20, 2014
sendData to ABAP backend via multiple form content type