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里面 只要将注释掉的部分注释掉就好了.
随机推荐
- THML
结构<!DOCTYE html> <html> <head> <meta charset="UTF-8> <titie>< ...
- Van Emde Boas Tree
van Emde Boas trees 支持所有优先级优先级队列的操作,并且巧妙的是它对于SEARCH, INSERT,DELETE,MINIMUM,MAXMUN,SUCCESSOR,和PREDECE ...
- leetcode题解2. Add Two Numbers
题目: You are given two non-empty linked lists representing two non-negative integers. The digits are ...
- APPicon的生成
APPIcon 工厂图标的生成:http://icon.wuruihong.com/#/home
- scrapy框架的日志等级和请求传参
日志等级 请求传参 如何提高scrapy的爬取效率 一.Scrapy的日志等级 - 在使用scrapy crawl spiderFileName运行程序时,在终端里打印输出的就是scrapy的日志信息 ...
- IDEA java编译中出现了Exception in thread “main" java.lang.UnsupportedClassVersionError
这个问题确实是由较高版本的JDK编译的java class文件试图在较低版本的JVM上运行产生的错误. 在idea中需要修改的有两区,四个地方 1. 修改项目编译器 Crtl+Shift+A 进入如下 ...
- 解决PLSQL报错及配置InstantClient方法
某次,在使用PLSQ链接数据库的时候,出现了错误如下: 然后点击窗口上面的 工具 –> 首选项 –> Oracle –> 连接 ,然后看到这样的窗口: 用电脑根据上面的地址搜索不到 ...
- Codeforces1076E. Vasya and a Tree(dfs+离线+动态维护前缀和)
题目链接:传送门 题目: E. Vasya and a Tree time limit per test seconds memory limit per test megabytes input s ...
- 《DSP using MATLAB》Problem 7.5
- stylelint 安装配置
1.安装 stylelint: npm i stylelint -g npm i stylelint stylelint-config-standard --save-dev 2.在 scripts ...