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