Handler execution resulted in exception: Content type 'application/json;charset=UTF-8' not supported
来源:互联网 发布:linux返回上一步 编辑:程序博客网 时间:2024/06/16 12:27
1、前台
$("#ajax2").click(function(){ var arrays = [{"id":"001", "name":"小敏1", "sex":"女", "age":22},{"id":"002", "name":"小敏1", "sex":"女", "age":22}]; $.ajax({ type:"POST", url:"ajax2.do", dataType:"json", contentType:"application/json", data:JSON.stringify(arrays), success:function(data){ } }); });
或者
$("#ajax2").click(function(){ var url = "ajax2.do"; var arrays = [{"id":"001", "name":"小敏1", "sex":"女", "age":22},{"id":"002", "name":"小敏1", "sex":"女", "age":22}]; $.ajaxSetup({ contentType:'application/json' }); $.post(url, JSON.stringify(arrays), function(response){ }, "json"); })
2、后台
@RequestMapping(value = "ajax2.do",method = RequestMethod.POST) public void ajax2(@RequestBody List<Student> list){ System.out.println(list.size());}注意:经过测试低版本的Spring MVC和高版本的Spring MVC 需要的jar包不同,具体版本限制我没有去测试。
我用的Spring MVC 是4.2的属于高版本,需要的jar包如下:
<!-- Spring MVC json --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.7.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.7.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.7.4</version> </dependency>低版本需要的jar包是:
<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency>
0 0
- Handler execution resulted in exception: Content type 'application/json;charset=UTF-8' not supported
- HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
- SPringMVC在使用JSON的数据传输时Error: Content type 'application/json;charset=UTF-8' not supported
- SpringMVC在使用JSON时出现Error: Content type 'application/json;charset=UTF-8' not supported
- Okhttp3问题 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
- Content type 'text/plain;charset=UTF-8' not supported
- AjaxAnywhere content-type in not text/xml : [text/json;charset=UTF-8]
- Content type expected:<application/json;charset=UTF-8> but was:<application/hal+json;charset=UTF-8>
- Retrofiy学习"Content-Type: application/json;charset=UTF-8"@Body的使用
- HttpMediaTypeNotSupportedException: Content type 'application/json;' not supported 问题原因之一
- 获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- 获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- (转)获取 request 中用POST方式"Content-type"是"application/x-www-form-urlencoded;charset=utf-8"发送的 json 数据
- header("Content-Type:text/html;charset=utf-8");
- header('Content-Type: text/html; charset=utf-8');
- header('Content-Type: text/html; charset=utf-8');
- header("Content-type:text/html;charset=utf-8")含义
- header("Content-type:text/html;charset=utf-8");
- DBCC IND跟DBCC PAGE简介
- ORACLE数据库中将clob查询结果展开
- Android BluetoothAdapter
- Android编程常见问题之六
- mysql函数
- Handler execution resulted in exception: Content type 'application/json;charset=UTF-8' not supported
- 查找某个进程拥有的所有窗口
- How tomcat works——7 日志记录器
- 修改Android签名证书keystore的密码、别名alias以及别名密码
- http://blog.sina.com.cn/s/blog_ebbe6d790102vmez.html
- VC++动态连接库详解
- DALI
- json 简单示例
- AJAX 跨域请求 - JSONP获取JSON数据