zoukankan      html  css  js  c++  java
  • 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 = "/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); } }
  • 相关阅读:
    [P4721] 【模板】分治 FFT
    [GYM102452E] Erasing Numbers
    [LOJ6220] sum
    [CF776B] Sherlock and His Girlfriend
    [LOJ6087] 毒瘤题
    [LOJ2612] 花匠
    [LOJ529] 自然语言
    [CTSC2017] 吉夫特
    [LOJ6671] EntropyIncreaser 与 Minecraft
    [LOJ3196] 挂架
  • 原文地址:https://www.cnblogs.com/shouwangzhe-/p/3936675.html
Copyright © 2011-2022 走看看