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的更多相关文章

  1. 遇到问题之“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 ...

  2. Spring Boot报错 MultipartException The temporary upload...

    Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ...

  3. Spring Boot 报错记录

    Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ...

  4. 启动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 ...

  5. 初学 Spring boot 报错 Whitelabel Error Page 404

    按照教程,写了个最简单的 HelloWorld,尼玛报错 -->Whitelabel Error Page 404. 网上99%都是项目结构不对,说什么 Application放在父级 pack ...

  6. 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 ...

  7. 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 ...

  8. spring boot 报错 Failed to read HTTP message

    2008-12-13 15:06:03,930 WARN (DefaultHandlerExceptionResolver.java:384)- Failed to read HTTP message ...

  9. Spring boot 报错 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

    在实际开发中修改别人的代码,发现了这个报错,后来发现是因为pom.xml里面 只要将注释掉的部分注释掉就好了.

随机推荐

  1. 剑指Offer 12. 数值的整数次方 (其他)

    题目描述 给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方. 题目地址 https://www.nowcoder.com/practice/ ...

  2. 剑指Offer 42. 和为S的两个数字 (其他)

    题目描述 输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 输出描述: 对应每个测试案例,输出两个数,小的先输出. 题目 ...

  3. Vue+WebSocket 实现页面实时刷新长连接

    最近vue项目要做数据实时刷新,折线图每秒重画一次,数据每0.5秒刷新一次,说白了就是实时刷新,因为数据量较大,用定时器估计页面停留一会就会卡死... 与后台人员讨论过后决定使用h5新增的WebSoc ...

  4. Power BI中DAX的动态计算方差

    我花了一点时间试图解决一个棘手的DAX表达式,那就是如何动态计算方差,下面我们认识一下这两个函数: PARALLELPERIOD  和 SAMEPERIODLASTYEAR  它能实现我们想要的结果, ...

  5. Python: Windows下pip安装库出错:Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat

    由于vs编译环境问题,需要设定vs2008的环境变量,如果机器上装有其他版本的vs比如vs2012, 可以做设定例如SET VS90COMNTOOLS=%VS120COMNTOOLS%即可

  6. 在linux中编译grpc

    环境: centos_7_x86_x64 一.下载 1)下载grpc源代码:grpc-1.2.0.zip 2)下载grpc依赖库: 1)benchmark-master.zip 2)boringssl ...

  7. zombodb 聚合函数

    zombodb 暴露基本上所有es 的集合函数为sql 函数,我们可以方便使用 比如 count FUNCTION zdb.count( index regclass, query zdbquery) ...

  8. 第2章 Java基本语法(上): 变量与运算符

    2-1 关键字与保留字 关键字(keyword) 保留字(reserved word) 2-2 标识符(Identifier) 案例 class Test{ public static void ma ...

  9. fork exec source的区别

    参考:http://www.cnblogs.com/bkygg/p/5023072.html 1:fork  运行的时候开一个sub_shell 执行调用的脚本,sub_shell执行的时候,pare ...

  10. Docker概念(二)

    说明:         一直想学Docker,容器.镜像.仓库什么的好难理解就没怎么看了,最近下定决心好好看看,google.Baidu发现这篇好文章,看完差不多有个大概的理解.里面的内容基本上来以下 ...