Required Integer parameter 'listId' is not present

POST請求接口,前端調用出現:org.springframework.web.bind.MissingServletRequestParameterException: Required Integer parameter 'listId' is not present

相關代碼:

@RequestMapping(value = "/updateXXX", method = RequestMethod.POST)
public JsonResult<Boolean> updateXXX(@RequestParam(value = "listId") Integer id) {}

原因:

request url: http://XXX/updateXXX?listId=1

 

 

 

將@RequestParam修改爲@RequestBody

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of START_OBJECT token

@RequestMapping(value = "/updateXXX", method = RequestMethod.POST)
public JsonResult<Boolean> updateXXX(@RequestBody Integer listId) {}

 


將Integer修改爲String

@RequestMapping(value = "/updateXXX", method = RequestMethod.POST)
public JsonResult<Boolean> updateXXX(@RequestBody String listId) {}
request url: http://XXX/updateXXX
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章