首页 > Web开发 > 详细

http请求后台报406错误

时间:2018-12-09 13:08:10      阅读:159      评论:0      收藏:0      [点我收藏+]

1.springMVC的项目,通过浏览器访问后台方法遇到了报406的错误,找了很多原因,最终发现是因为缺少spring-mvc的json配置。

技术分享图片

技术分享图片

 

2.添加依赖:jackson-databind、jackson-core-asl

3.在springMVC.xml中配置

<!-- 解决页面请求报406的错误 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>

4.在此访问即可

技术分享图片

 

http请求后台报406错误

原文:https://www.cnblogs.com/blue327/p/10090651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!