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. vue-cli 安装过程出现错误

    如果是这样得错误,那是你在安装sass得问题,需要安装python2,安装好就行了

  2. 马凯军201771010116《面向对象程序设计Java》第八周学习总结

    一,理论知识学习部分 6.1.1 接口概念 两种含义:一,Java接口,Java语言中存在的结构,有特定的语法和结构:二,一个类所具有的方法的特征集合,是一种逻辑上的抽象.前者叫做“Java接口”,后 ...

  3. disjoint set

    MAKE-SET.x/ creates a new set whose only member (and thus representative) is x. Since the sets are d ...

  4. oracle 查看字段说明

    SELECT    *FROM    all_col_commentsWHERE    table_name = UPPER ('t_bn_background')AND OWNER = 'VTER' ...

  5. java知识点归集

    将工作中,或者看书的过程中碰到的自己之前没有掌握的知识点进行归纳,暂时就碰到什么写什么,后续有一定量的话进行整理: 1.  list实现 相关文章:https://zhuanlan.zhihu.com ...

  6. Unity在UI界面上显示3D模型/物体,控制模型旋转

    Unity3D物体在UI界面的显示 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  7. windows下使用kafka的常用命令

    参考文档: https://blog.csdn.net/evankaka/article/details/52421314 http://orchome.com/6 1 启动zookeeper cmd ...

  8. hello2 源码解析

    在hello2的项目中,采用的是Java servlet  技术来采取对项目的整体框架的搭建.编写另一个greeting的java文件,实现了一个greeting的java类来覆盖url的doGet方 ...

  9. Introduction of filter in servlet

    官方给出的Filter的定义是在请求一个资源或者从一个资源返回信息的时候执行过滤操作的插件.我们使用过滤起最多的场景估计就是在请求和返回时候的字符集转换,或者权限控制,比如一个用户没有登录不能请求某些 ...

  10. java Scanner中next和nextLine()区别

    next(): 1.一定要读取到有效字符后才可以结束输入. 2.对输入有效字符之前遇到的空白,next() 方法会自动将其去掉. 3.只有输入有效字符后才将其后面输入的空白作为分隔符或者结束符. ne ...