The project was upgraded to spring boot 2.2.13, and an error occurred when using postman to test the interface: HttpMessageNotReadableException: Required request body is missing
The body data cannot be received in the interface of my own controller. The sample code is as follows:
@PostMapping(value = "/java/test/findByPage")
public Object findByPage(@RequestBody FilterVo filterVo) {
try {
logger.info(" findByPage filterVo{}", filterVo);
return "";
} catch (Exception e) {
logger.error("------", e);
return e;
}
}
The cause of this error is the Content-Type parameter in the request header.
Postman automatically sets this parameter to: "application/json;charset=UTF-8". Even if you set it to "application/json", it will become the previous one when requesting. Therefore, spring boot did not recognize it and did not convert it.
Solution:
"Content-Type" is set to "application/json", and the request interface is normal.
As for how to set postman[8.0.6] not to automatically add "chartset=UTF-8", please leave a message!
In addition, why do you mention the version of spring boot? Because this problem was not found in 2.2.6. As for which minor version this was changed to, I don’t know.