Springboot @ RequestBody cannot get the content-type= "application/json" request data

now I want to get a content-type=application/json callback data. Oddly enough, I can"t get the data using @ RequestBody, as shown in the following code:

@Data
public class BaiduDocNofityResponse {
    private String messageId;
    private String messageBody;
    private String notification;
    private String server;

    private String subscriptionName;
    private String version;
    private String signature;
}

@PostMapping("/doc/notify")
public void notify(@RequestBody BaiduDocNofityResponse response){
    log.info(":");
    log.info(response.toString());//****

}

but if you replace it with the following code, you can get it:

@PostMapping("/doc/notify")
public void notify(HttpServletRequest request) throws IOException {
    log.info("request content-type=" + request.getContentType());
    log.info(":" + request.toString());
    InputStream is = request.getInputStream();
    String val = StreamUtil.inputStream2String(is, "UTF-8");
    log.info(val);//****
}

does anyone know why?

Feb.26,2021

is not sent to you in JSON/Body format, you can use @ ModelAttribute instead of @ RequestBody, to get the value in Form/URL format. And the two ways of dealing with special types of format such as dates are not quite the same.


solved. Since log.info (response.toString ()); / / toString () here) doesn't work, if you get response.messageBody directly, I'm really drunk

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9d739-2f38c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9d739-2f38c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?