I have an interceptor. Before entering my controller, I read the body of the request. The original request is not repeatable, so I decided to wrap it with contentcacheingrequestwrapper. However, when using @ requestbody KBD> to receive parameters, the back-end reported an error. The log is as follows:
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing
Front end response is
{
"timestamp": "2021-07-21T11:53:55.637+0000",
"status": 400,
"error": "Bad Request",
"message": "Required request body is missing: public java.lang.String com.example.demo.controller.HelloController.post(com.example.demo.model.PostVO,javax.servlet.http.HttpServletRequest)",
"path": "/post"
}
It’s wrong. I’ve wrapped it up to be repeatable. After Google, stackoverflow didn’t find a solution, but
I found a description here. It says that contentcacheingrequestwrapper doesn’t overload the getinputstream method of httpservletrequestwrapper. This method will be used when receiving parameters with requestbody, So instead of using the contentcaching requestwrapper, I rewritten the httpservletrequestwrapper myself