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 注解去掉

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

 

完结!


目录
打赏
0
0
0
0
16
分享
相关文章
Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案
Content type ‘multipart/form-data;boundary=------57031299820747271;charset=UTF-8‘ not supported的解决方案
317 0
Posted content type isn't multipart/form-data
Posted content type isn't multipart/form-data
544 0
使用postMan调试接口出现 Content type ‘multipart/form-data;charset=UTF-8‘ not supported“
本文介绍了使用Postman调试接口时遇到的“Content type ‘multipart/form-data;charset=UTF-8’ not supported”错误,原因是Spring Boot接口默认只接受通过`@RequestBody`注解的请求体,而不支持`multipart/form-data`格式的表单提交。解决方案是在Postman中将请求体格式改为`raw`并选择`JSON`格式提交数据。
使用postMan调试接口出现 Content type ‘multipart/form-data;charset=UTF-8‘ not supported“
java实战小结-Controller报错:Content type ‘multipart/form-data;boundary=----WebKitFormBoundaryxxxx not supp
java实战小结-Controller报错:Content type ‘multipart/form-data;boundary=----WebKitFormBoundaryxxxx not supp
467 0
multipart/form-data和application/x-www-form-urlencoded的区别
在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型。 下边是说明: application/x-www-form-urlencoded: 窗体数据被编码为名称/值对。
1322 0
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
834 0
1113: No mapping for the Unicode character exists in the target multi-byte code page
什么是multipart/form-data请求
根据http/1.1 rfc 2616的协议规定,我们的请求方式只有OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE等,那为为何我们还会有multipart/form-data请求之说呢?这就要从头来说了。
1013 0

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等