Spring WebMVC 4.1返回json时导致的 406(Not Acceptable)问题

在Tomcat 7和Spring 4.1.4环境下,返回JSON数据时遇到406 Not Acceptable错误。通过排查发现可能与Spring版本有关。降低版本至4.0.9后问题解决。进一步分析4.0.9和4.1.0的源码,发现在JSON处理上有差异。最终,通过引入fasterxml库并在4.1.4版本下修复了问题。
摘要由CSDN通过智能技术生成

1.问题现象Tomcat7+Spring4.1.4,返回json字符串时发生406错误

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.

HTTP Status 406 -


type Status report

message

description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.


Apache Tomcat/7.0.52

2.具体实现
  @RequestMapping("/listAll")
  @ResponseBody
  public Map<String, Object> listAll() {
    List<Device> list = deviceService.listAll();
    if (list != null) {
      Map<String, Object> result 
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值