spring boot报Unsupported Media Type Content type '*/*;charset=UTF-8' not supported
1.请求设置Content-Type:application/json即可
ajax一般默认:Content-Type: application
/x-www-form-urlencoded
;charset=utf-8
2.服务端:
controller
package com.example.demo; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
public class helloController {
@RequestMapping(value="/hello")
public String say(){
String str="my spring boot web project hihihi";
System.out.println(str);
return str;
} @RequestMapping(value="/test")
public String testObj(@RequestBody User user){ System.out.println(user.toString());
return user.toString();
}
}
实体user
package com.example.demo; public class User {
private String userName;
private String pwd; public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getPwd() {
return pwd;
} public void setPwd(String pwd) {
this.pwd = pwd;
} public String toString(){
return userName+""+pwd;
}
}
3.输出
spring boot报Unsupported Media Type Content type '*/*;charset=UTF-8' not supported的更多相关文章
- 遇到问题之“postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported”
postman报Unsupported Media Type: Content type 'text/plain;charset=UTF-8' not supported postman之所以报Uns ...
- Spring Boot报错 MultipartException The temporary upload...
Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ...
- Spring Boot 报错记录
Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ...
- 启动Spring boot报错:nested exception is java.sql.SQLException: Field 'id' doesn't have a default value
先看具体日志: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with n ...
- 初学 Spring boot 报错 Whitelabel Error Page 404
按照教程,写了个最简单的 HelloWorld,尼玛报错 -->Whitelabel Error Page 404. 网上99%都是项目结构不对,说什么 Application放在父级 pack ...
- Spring Boot 报错:Error creating bean with name 'entityManagerFactory' defined in class path resource
spring boot 写一个web项目,在使用spring-data-jpa的时候,启动报如下错误: Error starting ApplicationContext. To display th ...
- Spring Cloud / Spring Boot There was an unexpected error (type=Unauthorized, status=401). Full authentication is required to access this resource.
访问EndPoint时会出现没有权限 There was an unexpected error (type=Unauthorized, status=401). Full authenticat ...
- spring boot 报错 Failed to read HTTP message
2008-12-13 15:06:03,930 WARN (DefaultHandlerExceptionResolver.java:384)- Failed to read HTTP message ...
- Spring boot 报错 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
在实际开发中修改别人的代码,发现了这个报错,后来发现是因为pom.xml里面 只要将注释掉的部分注释掉就好了.
随机推荐
- 剑指Offer 44. 翻转单词顺序列 (字符串)
题目描述 牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上.同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思.例如,"st ...
- pytorch中,不同的kernel对不同的feature map进行卷积之后输出某一个channel对应的多个feature map如何得到一个channel的feature map
实际上在卷积操作的时候,比如说,我某一层输出的feature map的size为4713*13 channel的数目为7,设经过某卷积层之后,网络输出的feature map的channel的数目为1 ...
- linux下GCC编译文件
Linux终端使用技巧: Ctrl+Alt+T打开终端 Ctrl+c死循环退出程序 Shift+Ctrl+T:新建标签页 Shift+Ctrl+N:新建窗口 Shift+Ctrl+Q:关闭终端 终端中 ...
- 【坑】https证书链不完整的坑
支付宝支付回调https失败,微信分享https连接在微信里打开空白,而chrome等浏览器访问正常. 是的,以上问题我作为半个运维在项目中遇到了,就是由于https证书链不完整引起的. 好吧,其实压 ...
- mod_conference ESL控制二(事件)
根据上篇所述功能需求,esl需要处理以下几类事件: ESL_EVENT_CHANNEL_* #channel相关事件,用户判断参会者是否应答.计费 DTMF事件 #识别参会者按键,根据按键进行操作( ...
- oracle note
null null为无效的,未指定的,未知的活不可预知的值 null不是空格或0 包含null 的数学表达式其结果都为空值 null 永远!= null 判断某个字段为null,用 ename is ...
- [C++/Python] 如何在C++中使用一个Python类? (Use Python-defined class in C++)
最近在做基于OpenCV的车牌识别, 其中需要用到深度学习的一些代码(Python), 所以一开始的时候开发语言选择了Python(祸患之源). 固然现在Python的速度不算太慢, 但你一定要用Py ...
- Delphi IdHTTP1下载文件防止假死 (
在Form1中添加控件:两个Indy控件:IdAntiFreeze1,IdHTTP1;一个按钮 :Button1;一个进度条 :ProgressBar1 显示下载速度 procedure TForm1 ...
- 图的遍历——DFS(矩形空间)
首先,这里的图不是指的我们一般所说的图结构,而是大小为M*N的矩形区域(也可以看成是一个矩阵).而关于矩形区域的遍历问题经常出现,如“寻找矩阵中的路径”.“找到矩形区域的某个特殊点”等等之类的题目,在 ...
- makefile或shell中的一些变量
总是记不住,作个笔记 $@ 所有目标文件 $< 第一个依赖文件的名称 $? 所有的依赖文件,以空格分开,这些依赖文件的修改日期比目标的创建日期晚 $^ 所有的依赖文件,以空格分开,不包含重复的依 ...