若使用默认的json转换器,则需要如下包;

<mvc:annotation-driven />

报错如下:

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

解决方案:

引入如下包:

问题既解决。

若使用外部的其他json转换,则需要配置相关的转换器

如:

<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
<bean
class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" />
<bean
class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean
class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
<!-- 配置fastjson中实现httpMessageConverter接口的转换器 -->
<bean id="fastJsonHttpMessageConverter"
class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter" >
<!-- 加入支持的媒体类型:返回contentType -->
<property name="supportedMediaTypes">
<list>
<!-- 这里顺序不能写反,一定先写text/html,不然IE会出现下载提示 -->
<value>text/html;charset:UTF-8</value>
<value>application/json;charset:UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:default-servlet-handler />

Spring MVC 前后台传递json格式数据 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported的更多相关文章

  1. 四:Spring Security 登录使用 JSON 格式数据

    Spring Security 登录使用 JSON 格式数据 1.基本登录方案 1.1 创建 Spring Boot 工程 1.2 添加 Security 配置 2.使用JSON登录 江南一点雨-Sp ...

  2. get请求传递json格式数据的两种方法

    get请求参数为json格式数据,使用pyhton+request的两种实现方式如下: 方法一:使用requests.request() 示例代码如下: 1.导入requests和json impor ...

  3. Spring MVC(七)--传递JSON参数

    有时候参数的传递还需要更多的参数,比如一个获取用户信息的请求中既有用户ID等基本参数,还要求对查询结果进行分页,针对这种场景,一般都会将分页参数封装成一个对象,然后将它和基本参数一起传给控制器,为了控 ...

  4. Spring MVC 学习笔记 json格式的输入和输出

    Spring mvc处理json需要使用jackson的类库,因此为支持json格式的输入输出需要先修改pom.xml增加jackson包的引用 <!-- json --> <dep ...

  5. Spring mvc 前后台通过json交互【转】

    原文转自:https://www.cnblogs.com/zhaojiankai/p/8184596.html 本节内容: @RequestBody @ResponseBody 请求json,响应js ...

  6. Spring MVC 返回 xml json pdf 数据的配置方法

    <!-- Spring MVC 返回 xml 数据的配置方法 -->     <bean class="org.springframework.web.servlet.vi ...

  7. Spring MVC中传递json数据时显示415错误解决方法

    在ajax中设置 ContentType为'application/json;charset=utf-8' 传递的data类型必须是json字符串类型:{“key”:"value" ...

  8. spring mvc 获取页面日期格式数据

    1.传递日期参数: 解决办法: 实体类日期属性加 @DateTimeFormat(pattern="yyyy-MM-dd") 注解 beans中加 <mvc:annotati ...

  9. Spring MVC 学习笔记11 —— 后端返回json格式数据

    Spring MVC 学习笔记11 -- 后端返回json格式数据 我们常常听说json数据,首先,什么是json数据,总结起来,有以下几点: 1. JSON的全称是"JavaScript ...

  10. ajax使用向Spring MVC发送JSON数据出现 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported错误

    ajax使用向Spring MVC发送JSON数据时,后端Controller在接受JSON数据时报org.springframework.web.HttpMediaTypeNotSupportedE ...

随机推荐

  1. [Linux]U盘启动盘安装CentOS7系统(LiveGNOME版)

    1 准备:工具 U盘 容量:视CentOS具体版本需要而定.推荐4G+ UltraISO(软碟通) ISO制作工具 / U盘启动盘刻录工具 2 制作:U盘启动盘 step1 下载CentOS镜像 Ce ...

  2. 还原win10任务管理器的内存dump功能之——程序逆向分析(待完成)

    逆向分析工作基本完成,笔记待完成.

  3. abp(net core)+easyui+efcore实现仓储管理系统——模块管理升级之上(六十一)

    Abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  4. 关于spring嵌套事务,我发现网上好多热门文章持续性地以讹传讹

    事情起因是,摸鱼的时候在某平台刷到一篇spring事务相关的博文,文章最后贴了一张图.里面关于嵌套事务的表述明显是错误的. 更奇怪的是,这张图有点印象.在必应搜索关键词PROPAGATION_NEST ...

  5. Centos7.x 安装配置Web性能压力测试工具Siege

    一.简介 Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重 ...

  6. std::cin 和 std::getline 混用的问题

    如果存在如下的输入, 11 is a prime 考虑如下的程序, std::cin>>number; std::getline(std::cin,input) std::cin 在读取数 ...

  7. vCenter报错:Log Disk Exhaustion on 10

    vCenter报错:Log Disk Exhaustion on 10 1.问题现象: 巡检时发现 vCenter Server 中,错误显示为:Log Disk Exhaustion on 10(字 ...

  8. Vue3 +element-plus+ wangEditor 富文本编辑器+前端七牛云上传

    我用的vue3,element-plus ,没用ts 搭建wangEditor 参考 地址 https://www.cnblogs.com/xbxxf/p/16791084.html 七牛云安装参考地 ...

  9. 做了个vscode 小插件,用于修改window 的颜色以区分同时打开的不同工作区,快用起来吧!

    Coralize marketplace/coralize 以高效且便捷的方式自定义Visual Studio Code工作区窗口的状态栏.标题栏以及活动边栏等颜色!这将对那些需要同时打开多个vsco ...

  10. Linux(centos7.9)搭建ldap服务器

    一.LDAP是什么 后期更新,目前只搭建了服务器 二.linux搭建LDAP服务器 以下服务器信息为该文档安装Radius服务环境 服务器信息:CentOS7  内核版本:3.10.0-1160.el ...