jquery与Spring @RequestBody注解的问题

由于jquery的get post请求 默认的contentType为:application/x-www-form-urlencoded;charset=UTF-8’,而我写的Java 接口的参数习惯性的写成了(@Request Object obj),这个时候前端报错error: “Unsupported Media Type”
message: “Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported”
path: “/user/login”
status: 415
timestamp: “2018-12-18T13:59:07.603+0000”,
头疼了很久,开始的时候通过在ajxa请求上添加contentType再将data转换成json,代码如图

$("#a").click(function () {
KaTeX parse error: Expected 'EOF', got '}' at position 328: … } }) }̲) ,虽然这个post请求成功….post(url,data,function)`,请求成功。
由于本人一直的项目是前后端分离,前端项目做的少,遇到这个问题,自己琢磨了几个小时,分享出来,希望对大家有帮助

猜你喜欢

转载自blog.csdn.net/codeydj/article/details/85081776
今日推荐