Spring MVC 3.2 406 Not Acceptable 这个报错主要是因为SpringMVC配置文件配置问题。

修改步骤如下:

首先,修改spring-mvc.xsd为 spring-mvc-3.2.xsd

其次,添加如下配置:

 <!--避免ajax请求出现406错误-->
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<!-- restful 是否采用扩展名的方式确定内容格式,id.json 返回JSON格式 -->
<property name="favorPathExtension" value="false" />
<!-- restful 是否采用参数支持确定内容格式,id?format=json 返回JSON格式 -->
<property name="favorParameter" value="false" />
<!-- restful 是否忽略掉accept header,Accept:application/json -->
<property name="ignoreAcceptHeader" value="false" />
<property name="mediaTypes" >
<value>
atom=application/atom+xml
html=text/html
json=application/json
*=*/*
</value>
</property>
</bean>

Spring MVC 3.2 406 Not Acceptable的更多相关文章

  1. Spring4 MVC json问题(406 Not Acceptable)

    最近使用spring4.0的Mvc,json请求时,客户端报错,406 Not Acceptable 解决方法: 1.导入第三方的fastjson包,fastjson-1.1.34.jar 2.Spr ...

  2. Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误。

    如题,最近以spring mvc作为后台框架,前端异步获取数据时(.html为后缀名的访问方式),报406 Not Acceptable错误.当初都不知道啥原因,前后台都没报错就是返回不了数据,于是查 ...

  3. Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误

    转载,感谢这位博主,有自己的添加. 如题,最近以spring mvc作为后台框架,前端异步获取数据时(.html为后缀名的访问方式),报406 Not Acceptable错误.当初都不知道啥原因,前 ...

  4. spring mvc 406 (Not Acceptable) json转换错误

    spring mvc通过@RequestMapping("/register")和@ResponseBody返回json格式的字符串时出现如下异常: The resource id ...

  5. Spring MVC 的json问题(406 Not Acceptable)

    原因 : 就是程序转换JSON失败. 在pom.xml 加上 <dependency> <groupId>com.fasterxml.jackson.core</grou ...

  6. Spring mvc 下Ajax获取JSON对象问题 406错误

    我在学习springmvc过程中(我的项目是配置的后缀是.html),从controller返回对象. 如果我不使用 mvc-annotation-driver,而是手动配置,AnnotationMe ...

  7. Spring MVC控制器用@ResponseBody声明返回json数据报406的问题

    本打算今天早点下班,结果下午测试调试程序发现一个问题纠结到晚上才解决,现在写一篇博客来总结下. 是这样的,本人在Spring mvc控制层用到了@ResponseBody标注,以便返回的数据为json ...

  8. Spring mvc下Ajax获取JSON对象问题 406错误

    spring 通过@ResponseBody标签返回JSON数据的方法都报406错: Failed to load resource: the server responded with a stat ...

  9. Spring WebMVC 4.1返回json时 406(Not Acceptable)

    1.问题现象Tomcat7+Spring4.1.4,返回json字符串时发生406错误 The resource identified by this request is only capable ...

随机推荐

  1. hdoj 1698 Just a Hook【线段树区间修改】

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. PHP文件的上传下载

    一.文件的上传 1.客户端设置: (1).在 标签中将enctype和method两个属性指明相应的值. Enctype="multipart/form-data"; Method ...

  3. Javascript substr方法在某些浏览器下行为出现BUG的补丁代码

    主要思路是使用兼容性和稳定性都保持一致的substring方法重写/覆盖substr /** * String.substr() bug fix * @param start * @param len ...

  4. ASP.NET MVC提交到服务器的几种方法

    多年不搞WEB开发了,最近有个小活干干,记录一下学习的心得. 以下为几种脚本向服务器提交的方法: 1. $.ajax({ type: "GET", url: "/Test ...

  5. java 大数据处理之内存溢出解决办法(一)

    http://my.oschina.net/songhongxu/blog/209951 一.内存溢出类型 1.java.lang.OutOfMemoryError: PermGen space JV ...

  6. BringWindowToTop(), SetForegroundWindow(), SetActiveWindow()

    1. SetActiveWindow() 原型: <span style="font-size:14px;">CWnd* SetActiveWindow(); HWND ...

  7. [D3] 13. Cleaner D3 code with selection.call()

    selection.call() method in D3 can aid in code organization and flexibility by eliminating the need t ...

  8. android82 文件下载框架xUtils

    package com.itheima.xutils; import java.io.File; import com.lidroid.xutils.HttpUtils; import com.lid ...

  9. Eclipse Key Shortcuts for Greater Developers Productivity--reference

    Posted by Ajitesh Kumar / In Java / June 6, 2014 http://vitalflux.com/eclipse-key-shortcuts-greater- ...

  10. java 窗口的一些示例代码,可直接运行

    代码链接如下: http://pan.baidu.com/s/1gdlCI4N 有应用SWING,也有应用AWT,可视情况而定. 窗口程序运行需要jdk1.7环境(测试可用).