[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序

问题:前端传json,后端也返回json,出现格式不匹配报415问题!!!!

 

1.maven引入jackson包,共3个【重要】[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序

获得 jackson-annotation jar包的教程如下

https://www.cnblogs.com/dlsunf/p/9855195.html

 

2.springmvc的配置文件【重要】

[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序


4.前端(微信小程序Ajax)【重要】
最好在headers中限制一下传输和接收的内容格式

[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序


5.后端【很简单】

[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序
下面是业务代码,所以没截图了


maven引入jackson包后

大工造成了!!

[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序[实用!]SpringMVC与微信小程序JSON交互时 @RequestBody,415Unsupported Media Type错误 微信小程序