Failed to load resource: the server responded with a status of 406 (Not Acceptable)问题的解决方案
来源:互联网 发布:知水牌富氢水杯的价格 编辑:程序博客网 时间:2024/06/06 02:50
使用SpringMVC时,我们经常需要在Controller里返回一个对象,以json的方式传给视图。
可能会遇到如下问题:
Failed to load resource: the server responded with a status of 406 (Not Acceptable)
引发这问题的可能性有好几种,我遇到这个是因为json转换的问题。
我们在SpringMVC的配置文件中加上如下配置即可:
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> <bean class="org.springframework.http.converter.FormHttpMessageConverter" /> <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter" /> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg index="0" value="UTF-8" /> </bean> </mvc:message-converters></mvc:annotation-driven>
当然要引入相关的jar包,我这里使用的是maven,需要的依赖如下:
<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version></dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.6.3</version></dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.6.3</version></dependency><dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.6.3</version></dependency>
对应的jar包为:
jackson-mapper-asl-1.9.13.jar
jackson-core-asl-1.9.13.jar
jackson-annotations-2.6.3.jar
jackson-core-2.6.3.jar
jackson-databind-2.6.3.jar
如果用Maven下载包的时候太慢,可以直接使用我上传的资源:http://download.csdn.net/detail/lianjiww/9740986
把这个资源下载下来直接考到本地Maven仓库即可。
1 0
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)问题的解决方案
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)
- SprimgMVC:Failed to load resource: the server responded with a status of 406 (Not Acceptable)
- springmvc获取json Failed to load resource: the server responded with a status of 406 (Not Acceptable)
- Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
- jquery:Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- the server responded with a status of 406 (Not Acceptable)
- Spring MVC json报406错误的解决办法 Failed to load resource: the server responded with a status of 406
- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- failed to load resource the server responded with a status of 500 (internal server error)
- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- failed to load resource the server responded with a status of 500 (internal server error)
- SrpingMVC==>Failed to load resource: the server responded with a status of 404(Not Found)
- (springmvc)页面找不到静态资源文件Failed to load resource: the server responded with a status of 404 (Not Found)
- SharePoint Debug - Failed to load resource: the server responded with a status of 500
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- 文件复制代码
- Spark源码学习(一)---Spark的启动脚本
- shell 定时备份mysql
- linux下redis设置开机自启动
- IO流_File类的创建功能
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)问题的解决方案
- nodejs spread operator(三个点)
- A/B 数论 逆元 待补完
- 腾讯游戏MySQL数据一致性校验及在线修复实践
- Protocol Buffer
- 认知医疗
- SQLite的SQL语法
- POJ - 3026
- hdu1573 X问题 中国剩余定理 待补完