最近使用spring4.0的Mvc,json请求时,客户端报错,406 Not Acceptable

解决方法:

1、导入第三方的fastjson包,fastjson-1.1.34.jar

2、Spring配置文件添加:

<mvc:annotation-driven>  
    <mvc:message-converters register-defaults="true">  
        <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->  
        <bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">  
            <property name="supportedMediaTypes">  
                <list>  
                    <value>application/json;charset=UTF-8</value>  
                </list>  
            </property>  
        </bean>  
    </mvc:message-converters>  
</mvc:annotation-driven>

 

相关文章:

  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2021-10-31
猜你喜欢
  • 2021-09-17
  • 2021-05-21
  • 2021-09-16
  • 2022-12-23
  • 2021-08-03
  • 2021-07-16
  • 2021-08-01
相关资源
相似解决方案