起因:在springmvc与angularjs框架结合下,学习springSecurity,在用$http.post()请求是,报以下错误:

异常:

SpringMVC标签@RequestBody与angularJS中$http.post()请求引起415问题

 解决:出现这个问题是搜了很多关于415异常的问题解答,都是在讲前端发出请求时参数的Content-Type并不是后端解析所需,             但是@RequestBody解析数据正是需要json字符串,所以搜出的答案没有解决问题。后来在国外的一个论坛上找到了答案(https://stackoverflow.com/questions/33251411/requestbody-not-workin-http-status-415),才发现是springmvc配置文件中

<mvc:annotation-driven/>

 未配置。在xml文件中配置下即可!

后续:搜了下该配置的作用,默认会帮我们注册默认处理请求,参数和返回值的类。

          详细内容可参考https://my.oschina.net/u/1156626/blog/881483

 

         

 

 

相关文章:

  • 2021-11-20
  • 2021-07-09
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2021-11-20
  • 2022-12-23
  • 2021-11-10
  • 2021-12-31
  • 2022-01-10
相关资源
相似解决方案