标签:header cte fast resource ref source ble code ring
下面是在开发过程中遇到过的各种码,自己的问题自己的原因,同码不同错,贱笑贱笑。
HTTP 406 Not Acceptable
这个错误的原因,是由于框架使用了`SpringMVC`中的`ResponseBody`注解,相关的json包全有,包括:
‘org.codehaus.jackson:jackson-mapper-asl:1.9.13‘, ‘org.codehaus.jackson:jackson-core-asl:1.9.13‘,
‘com.fasterxml.jackson.core:jackson-core:2.8.4‘,
‘com.fasterxml.jackson.core:jackson-databind:2.8.4‘,
‘com.fasterxml.jackson.core:jackson-annotations:2.8.4‘
这哥几个算是json界里的名人了,我的项目里面全都有,但是任然报错,406 。查阅了下406的最官方定义,原文大致如下:
406 Not Acceptable The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
参考翻译:由请求标识的资源(resource),仅能够生成具有根据在请求中发送的接受报头而不可接受的内容特性的响应实体。(就酱,凑活着看吧)
就是说,我在代码中添加的这个东西:
produces = {"application/json;charset=UTF-8"}
它表示返回的数据要能造型成JSON的格式才行,否则就会爆406的错误。我改了下代码的返回数据的形式,重启服务,结果可行,错误“完美”解除。
标签:header cte fast resource ref source ble code ring
原文地址:http://www.cnblogs.com/SummerinShire/p/6344645.html