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. 《JavaScript Dom 编程艺术》读书笔记-第4章

    我的前端入门第一本书是<JavaScript Dom 编程艺术>,网上查找资料发现前端的入门推荐书籍最受好评的就是这本和<JavaScript 高级程序设计>了.之所以先选这本 ...

  2. Java 1.7 NQuery

    package org.rx.common; import java.lang.reflect.Array; import java.util.*; /** * Created by wangxiao ...

  3. 互联网创业公司如何防御 DDoS 攻击?采用CDN服务

    收集了发表于2015年 攻击者是控制一个足够大的分布式集群来发起攻击,各种杂七杂八的包,什么都会有.根本不在乎你开的什么服务,也没那耐心分析你有什么服务.比如哪怕你根本没开UDP的任何服务,但他就是发 ...

  4. Linux下截屏方法

    参考百度经验 https://jingyan.baidu.com/article/48a42057c8e8dfa92525047c.html 第一种: 截屏部分画面并保存 快捷键Shift+PrtSc

  5. Power BI和 Visio 集成优缺点

    Power BI 的 Visio 自定义视觉,这个功能是非常值得让人兴奋的,小悦相信这是一个非常重要的开发,不仅适用于 Visio,也适用于Power BI.现在已经有越来越多的可视化,它们以更简洁的 ...

  6. C/C++ 宏技巧

    1. C 也可以模板化 #define DEFINE_ARRAY_TYPE(array_type_, element_type_) \ static inline int array_type_ ## ...

  7. 利用exosip DNS CACHE自定义SIP服务器地址和端口

    文章标题可能表述不清,罢了,我这里描述一个场景: 当使用exosip开发UA时,服务器地址是域名example.com和端口形式,但存在两个限制: 1.example.com没有DNS记录.没有NAP ...

  8. PTA——黑洞数

    PTA 7-44 黑洞数 我的程序,一个用例通不过 #include<stdio.h> void sort(int *a,int n); int main() { ; scanf(&quo ...

  9. 学习笔记(二)--Lucene简介

    Lucene简介 最受欢迎的java开源全文搜索引擎开发工具包.提供了完整的查询引擎和索引引擎,部分文本分词引擎(英文与德文两种西方语言).Lucene的目的是为软件开发人员提供一个简单易用的工具包, ...

  10. java_字段声明

    多字段继承,为避免混淆,simple name与qualified name的使用 package java20180129_1; interface Frob { float v=2.0f; } c ...