Spring boot ajax 400 错误,数据为Null一直
早上配置了一下ajax :
正确代码:
后台代码 :
前台:
1.错误情况 访问参数不存在 required String parameter 'addreLike' is not present :
前台代码:
后台:
错误返回值:
{"timestamp":1520911779601,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required String parameter 'addreLike' is not present","path":"/postLocation"}
错误请求:
参数明显传递的有问题:
---确定访问到了后台链接, 加上 required=false;参数可空:
再次访问 打印了日志,证明我们的url 是对的, 断点发现 参数都为Null
2错误 参数一直为Null
看到
请求参数,一堆码肯定有问题。正确的应该是键值对的形式,
好吧,那就是contentType: 的问题。 参考帖子:https://www.cnblogs.com/xiaozong/p/5732332.html
替换了 contentType
访问成功:
.......
?
contentType: application/json应该在什么情况下是可以访问的,参数格式,