spring 通过@ResponseBody标签返回JSON数据的方法都报406错: Failed to load resource: the server responded with a status of 406 (Not Acceptable) 以及报错描述: The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers () 

 

Spring  配置如下:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
 
mediaTypes配置:                
        atom=application/atom+xml  
           html=text/html  
           json=application/json  
           *=*/*
用@ResponseBody返回对象出现问题,报406错误!!!
最后发现是:spring 时requestedMediaTypes却为[text/html]的情况报406错误,还有一个原因可能是由于采用的后缀有关,如果使用*.htm,*.html等,默认就会采用[text/html]编码,若把AJAX请求URL后面加上*.json,*.shtml等就OK

最新文章

  1. 学习.NET是因为热爱 or 兴趣 or 挣钱?
  2. 虚拟化平台cloudstack(6)——使用maven:jetty调试
  3. mongo数据备份及恢复脚本
  4. js 获取iframe中的元素
  5. Mycat配置文件rule.xml
  6. JavaScript中关于bool类型判断的一些总结。
  7. I2C实时时钟rx-8025板卡实际应用
  8. spark on hive 配置hive的metastore为mysql
  9. Android开发-API指南-<uses-configuration>
  10. initWithSpriteFrameName和createWithSpriteFrameName
  11. 帝国cms如何调用栏目别名作为分类标题?[!--classname--]标签不能用
  12. Oauth认证简介
  13. KeystoneJS+mongo搭建简易博客
  14. ural1097 Square Country 2
  15. Matlab中plot函数全功能解析
  16. jvisualvm 连接 jstatd 远程监控 jvm 或 Visual GC提示"不受此JVM支持“
  17. [DIOCP视频]-DIOCPFileServer视频
  18. caffe rpn layer 中的 reshape layer
  19. Jenkins+Sonar集成对代码进行持续检测
  20. JAVA_SE_Day02 String 的正则表达式

热门文章

  1. nginx(二)支持websocket配置
  2. Centos7.4修改主机名HostName颜色及格式
  3. Xilinx的ISE14.7和PlanAhead与win10系统的兼容性问题解决方案
  4. Asp.Net MVC上传图片
  5. cx_Oracle读写clob
  6. nlp资料网站
  7. spring源码:学习线索
  8. JavaScript 字符串与json对象互转的几种方法
  9. 第四百零二节,Django+Xadmin打造上线标准的在线教育平台—生产环境部署,uwsgi安装和启动,nginx的安装与启动,uwsgi与nginx的配置文件+虚拟主机配置
  10. window、Linux 文本文件转换