SpringMVC返回JSON时406错误
2015-05-18 16:37
375 查看
整合Spring+SpringMVC时意外出现了406错误,这里记录一下。
applicationContext-mvc.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
">
<context:component-scan base-package="com.raycloud" />
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
报错:
解决办法:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
applicationContext-mvc.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
">
<context:component-scan base-package="com.raycloud" />
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
报错:
解决办法:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
相关文章推荐
- springmvc 返回 json报406错误
- springMVC返回json时报406错误的bug
- springMVC 中url后缀使用html,不能返回json数据,否则会报406错误
- springmvc返回json数据406错误的解决办法
- SpringMVC 利用@ResponseBody注解返回Json时,出现406 not acceptable 错误的解决方法。
- SpringMVC返回JSON数据406错误处理
- springmvc返回json格式数据报406错误
- 解决springmvc 返回JSON报406错误
- spring后台返回json数据 页面406错误 Not Acceptable解决
- @ResponseBody返回JSON数据时遇到406错误
- ssm框架返回json .do 406 (Not Acceptable)错误
- spring返回 json报406错误
- springMVC浏览器接受json报406错误的解决方法
- springmvc访问返回数据类型格式化json报http status 406 和json时间格式化
- springMVC浏览器接受json报406错误的解决方法
- springmvc中 ajax请求错误,返回406,并一直进入error的回调方法,以及返回参数为Object
- Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理 .
- 关于springMVC 4.x配置ajax-json 出现406错误的问题。
- Spring MVC 返回json数据 报406错误 问题解决方案
- maven spring restful 以json返回时,如果出现406错误该如何处理