【问题标题】:Status 400 The request sent by the client was syntactically incorrect. Angularjs http状态 400 客户端发送的请求在语法上不正确。 Angularjs http
【发布时间】:2015-08-13 00:59:20
【问题描述】:

我在服务器上有弹簧控制器:

@RequestMapping(value = "/lab/getAlgo", method = RequestMethod.POST)
    public @ResponseBody Algo14web  getPicksByLeague(@RequestBody AlgoRequest request) {
    ...

类算法请求:

class AlgoRequest{
        public int id;
        public int limit; // I tried change to double and float too
    }

还有 AngularJS:

$http.post(urlSer.url+"lab/getAlgo",{id:1,limit:2.5});

当客户端向服务器发送请求时得到Status 400 The request sent by the client was syntactically incorrect

【问题讨论】:

  • 想知道$http.post(urlSer.url+"/lab/getAlgo",{id:1,limit:2.5}); 是否可行

标签: javascript java angularjs spring


【解决方案1】:

这是因为2.5 不是整数。

您的AlgoRequest 类要求limit 字段为整数,但您尝试将2.5 传入。它在语法上不正确,因为您没有提供符合整数语法的值。

【讨论】:

  • 我将课程改为AlgoRequest{ public int id; public double limit; },但我仍然收到一些消息
猜你喜欢
  • 1970-01-01
  • 2015-12-22
  • 1970-01-01
  • 2017-01-22
  • 1970-01-01
  • 1970-01-01
  • 2015-12-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多