这是我控制器的一部分:
@RequestMapping(value = "/addPerson", method = RequestMethod.POST)
public void addPerson(@RequestParam("name") String name, @RequestParam("surname") String surname){
//...
}
这是我的cURL:
curl -X POST http://localhost:8080/addPerson?name=John&surname=Doe
请求失败:
{"timestamp":"2019-10-02T06:10:48.172+0000","status":400,"error":"Bad Request","message":"Required String parameter 'surname' is not present","path":"/addPerson"}
答案 0 :(得分:0)
我通过将URL放在引号中解决了这个问题:
curl -X POST "http://localhost:8080/addPerson?name=John&surname=Doe"