码迷,mamicode.com
首页 > 其他好文 > 详细

The request sent by the client was syntactically incorrect. 400 问题

时间:2014-08-26 11:17:46      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   问题   div   

  The request sent by the client was syntactically incorrect.

  这个问题是因为 SpringMvc controller 里面的方法参数和请求参数不匹配。

 

请求参数在 Contoller 的方法参数对象中不存在则会报这个错误。

如 :

  Controller 里面的方法

@RequestMapping(value = "/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 问题

标签:style   blog   http   color   os   io   ar   问题   div   

原文地址:http://www.cnblogs.com/shouwangzhe-/p/3936675.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!