首页 > 代码库 > The request sent by the client was syntactically incorrect. 400 问题
The request sent by the client was syntactically incorrect. 400 问题
The request sent by the client was syntactically incorrect.
这个问题是因为 SpringMvc controller 里面的方法参数和请求参数不匹配。
请求参数在 Contoller 的方法参数对象中不存在则会报这个错误。
如 :
Controller 里面的方法
@RequestMapping(value = "http://www.mamicode.com/login/signin", method = RequestMethod.POST) public @ResponseBody Person login(HttpServletRequest request, @RequestBody Person person){ //... }
public class Person { private int id; private String name; //... set get}
function init() { var url = "login/signin"; var req = new Object();
req.id = 1; req.name = "aaa"; req.age = 18; // Person 没有age 属性. (function() { $.ajax({ type : ‘post‘, url : url, contentType : ‘application/json‘, datatype : ‘json‘, data : JSON.stringify(req), success : processSuccess, error : processError }); })(); function processSuccess(result) { alert("success--"+result); } function processError(result) { alert("error--"+result); } }
The request sent by the client was syntactically incorrect. 400 问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。