Spring mvc下Ajax获取JSON对象问题 406错误
2024-10-12 04:36:37
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!
最新文章
- 学习.NET是因为热爱 or 兴趣 or 挣钱?
- 虚拟化平台cloudstack(6)——使用maven:jetty调试
- mongo数据备份及恢复脚本
- js 获取iframe中的元素
- Mycat配置文件rule.xml
- JavaScript中关于bool类型判断的一些总结。
- I2C实时时钟rx-8025板卡实际应用
- spark on hive 配置hive的metastore为mysql
- Android开发-API指南-<;uses-configuration>;
- initWithSpriteFrameName和createWithSpriteFrameName
- 帝国cms如何调用栏目别名作为分类标题?[!--classname--]标签不能用
- Oauth认证简介
- KeystoneJS+mongo搭建简易博客
- ural1097 Square Country 2
- Matlab中plot函数全功能解析
- jvisualvm 连接 jstatd 远程监控 jvm 或 Visual GC提示";不受此JVM支持“
- [DIOCP视频]-DIOCPFileServer视频
- caffe rpn layer 中的 reshape layer
- Jenkins+Sonar集成对代码进行持续检测
- JAVA_SE_Day02 String 的正则表达式
热门文章
- nginx(二)支持websocket配置
- Centos7.4修改主机名HostName颜色及格式
- Xilinx的ISE14.7和PlanAhead与win10系统的兼容性问题解决方案
- Asp.Net MVC上传图片
- cx_Oracle读写clob
- nlp资料网站
- spring源码:学习线索
- JavaScript 字符串与json对象互转的几种方法
- 第四百零二节,Django+Xadmin打造上线标准的在线教育平台—生产环境部署,uwsgi安装和启动,nginx的安装与启动,uwsgi与nginx的配置文件+虚拟主机配置
- window、Linux 文本文件转换