spring mvc HTTP Status 406 错误

作者: 凯哥Java | 来源:发表于2018-01-01 10:45 被阅读6次

错误信息:

查看spring-mvc的配置文件:

再次查看错误信息:

description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().其字面意思:产生的格式跟能接受的格式不符。查询多种资料都说什么没有添加json支持的包。于是查看依赖:

存在的。

接着查找:

发现Spring默认ContentNegotiationManager使用org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy解析可接受的media type,这貌似是Spring 3哪个版本以后开始的特性解决方案:在spring-mvc.xml文件中添加:

​说明:如果配置文件中使用了。以上两个bean需要定义在其之前呢。

凯哥Java

相关文章

网友评论

    本文标题:spring mvc HTTP Status 406 错误

    本文链接:https://www.haomeiwen.com/subject/huttnxtx.html