ajax+jason=http 406
来源:互联网 发布:gephi输入数据 编辑:程序博客网 时间:2024/06/05 03:00
(1)错误:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers.
这分明是说我的请求资源有响应,但是呢,请求消息头headers里的Accept并不能接受这种响应。
通俗一点:我服务器返回的是json数据,但是跟我请求的数据类型不同[Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8].
我的controller方法,如下图
用eclipse的Monitor监视结果,如下图
(2)解决办法:web.xml我使用 url-pattern拦截所有以html结尾的请求,而SpringMVC规定:在SpringMVC中如果请求以html结尾,那么就不会返回JSON数据。
改成.do就行了
返回的json数据在网页上展示
除此之外,此问题的还有其他原因,最主要的就是看jackson依赖的jar包有没有冲突。
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.9</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.8.9</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.8.9</version> </dependency>
(3)查找了几个参考的博文和论坛:
1.Http请求中Content-Type讲解以及在Spring MVC中的应用
2.Spring WebMVC 4.1返回json时导致的 406(Not Acceptable)问题
3. json转换错误:No converter found for return value of type
4.Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理
5.Spring MVC + JSON = 406 Not Acceptable
- ajax+jason=http 406
- Jason
- ajax之jason发送到服务器端
- struts2+ajax获取jason数据失败
- struts2+ajax 获取jason数据错误
- (6)ajax+jason实现分页查询
- 使用beego异步传递ajax的jason
- jason jason jason
- struts2 jquery ajax 返回jason类型遇到问题总结
- http://jason.digitalinertia.net/dockered-dpdk-packaging-open-vswitch/
- AJAX | HTTP
- 记ajax请求出现http 406
- ajax显示jason类型的日期是发现只能显示出object
- Linux下的串口继续 转自http://www.cnblogs.com/jason-lu/articles/3173988.html
- jason数据格式
- android jason
- About Jason.
- Jason Suz
- PHP 正则表达式抓取网页内容。
- 文章标题
- shiro
- 数据结构——栈
- HackerRank leonardo-and-lucky-numbers —— 模线性方程的通解
- ajax+jason=http 406
- 【C#】真分页功能的实现
- 暑期集训—day3—hdu 4506, 2855, 1097-快速幂与矩阵快速幂
- 7月22日考试总结
- 安卓手机分区
- spark架构解析
- 虚函数实现说明
- 【代码片-1】 Servlet总结
- 深度学习优化函数详解(1)-- Gradient Descent 梯度下降法