获取状态代码为406,内容 - 响应头类型为text / html而不是application / json

时间:2015-04-02 13:43:57

标签: ajax json spring http-status-code-406

获取状态代码为406 "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers."

将spring版本(3.1.2升级到3.2.13)时,我从服务器收到406错误。

Content-Type of Response headers:"Content-Type:text/html;charset=utf-8". 
Request Header is Accept: application/json, text/javascript, */*; q=0.01. 
JavaCode:"@RequestMapping(value = "/search",method = RequestMethod.POST,consumes = "application/json", produces = "application/json")".

Ajax电话:

$.ajax({    
            url : /search.htm,
            dataType : json,
            data : postData,
            contentType: application/json,
            .
            .
            .});
  • Spring 3.2.13
  • 杰克逊 - 注解-2.1.2
  • 杰克逊 - 芯 - 2.1.2
  • 杰克逊核-ASL-1.9.9
  • 杰克逊 - 数据绑定-2.1.2
  • 杰克逊映射器-ASL-1.9.9

但在使用以下配置时,它的工作效果非常好。(此处为Content-Type的响应标头:application/json

  • Spring 3.1.2
  • 杰克逊核-ASL-1.9.9
  • 杰克逊映射器-ASL-1.9.9

请帮我解决此问题。

0 个答案:

没有答案