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里面 只要将注释掉的部分注释掉就好了.
随机推荐
- Problem D: 平面上的点——Point类 (IV)
Description 在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定.现在我们封装一个“Point类”来实现平面上的点的操作. 根据“append.cc”,完成Point类的构造方 ...
- nodejs -- require , exports , module
1. require , exports . -------------------------- 文件: 1) index.js //两种方式都可以: var forExports = requir ...
- ADO.NET 的五个对象
首先来一张关系图,了解大概关系. 知道了整个大关系之后,我们在具体看一下他们五个的分工: 1. SqlConnection 在访问数据时,我们首先必须要建立数据库的物理连接.· 2.SqlComman ...
- 【转载】 强化学习(十)Double DQN (DDQN)
原文地址: https://www.cnblogs.com/pinard/p/9778063.html ------------------------------------------------ ...
- 温度转换-python
#接收一段字符串 TempStr = input("请输入带有符号的温度值:") #如果 TS 最后一位是大写或是小写 f if TempStr[-1] in ['F','f']: ...
- 初窥async,await
首先是一道今日头条的面试题:(听说是今日头条的并且已经烂大街了) async function async1() { console.log( 'async1 start' ) await async ...
- linux数据库
sudo apt-get install mysql-server ---------Centos7下安装mysql 开始-------------下载mysql的repo源# yum install ...
- Mybatis Update操作返回值问题
https://www.cnblogs.com/jpfss/p/8918315.html
- 批量将某一目录下的.py文件改为.txt格式文件
#!/usr/env/python#-*- coding:utf-8 -*-#批量将某一目录下的.py文件改为.txt格式文件import os,os.pathfile_list = os.listd ...
- wmv 播放器
部分代码如下 QAction *openFile = new QAction(QIcon(QString(":/Res/open.png")), tr("打开文件&quo ...