版权声明:转载请注明出处 https://blog.csdn.net/u013837825/article/details/88366144
记录一次失败的SpringMVC请求
背景
- 后端接口
@ApiOperation(value = "获取精选评论列表")
@PostMapping("/getByIds")
@RestWrapper
public RestResult<List<Object>> getByIds(@RequestBody List<String> commentIds) {
return RestResult.SUCC(commentService.getByIds(commentIds));
}
启动服务…
- 使用postman进行自测
请求入参是在body里写上一个json字符串:
{
"commentIds":["5c820367f9768046361efcb9","5c820851f9768051c1fcafec","5c81fa52ed01b8087a3d0900"]
}
- 请求报错
错误信息如下:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]
...
- 解决方案
请求参数书写格式修正:
请求成功,背后的细节需要研究一个SpringMVC的请求了…
需要继续努力