这是我的Put请求的Controller映射:
@PutMapping("/voteForPostByUser")
public String vote(@RequestParam(value = "postId", required =
true) String postId, @RequestParam(value = "userId", required = true)
Integer userId, @RequestBody Boolean vote) {
BlogPostVoteDTO blogPostVoteDTO = new BlogPostVoteDTO
(postId, userId, vote);
return
this.blogPostService.updateBlogPostVotes(blogPostVoteDTO);
}
当我从POSTMAN运行以下请求时:
http://localhost:8082/microblog/api/voteForPostByUser?postId=5d564a2638195729900df9a6&userId=5
Request Body:
{
"vote" : true
}
我得到以下异常
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot deserialize instance of
`java.lang.Boolean` out of START_OBJECT token; nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of `java.lang.Boolean` out of START_OBJECT token\n
at [Source: (PushbackInputStream); line: 1, column: 1]",
"trace":
"org.springframework.http.converter.HttpMessageNotReadableException: JSON
parse error: Cannot deserialize instance of `java.lang.Boolean` out of
START_OBJECT token; nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of `java.lang.Boolean` out of START_OBJECT token\n
at [Source: (PushbackInputStream); line: 1, column: 1]\r\n\tat
我可能很简单,但我不明白我想念的是什么?
最佳答案
我像这样使用true或false尝试邮递员,没关系。
关于java - 无法从START_OBJECT token 中反序列化java.lang.Boolean的实例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57521183/