我现在想获取一个content-type=application/json的回调数据,奇怪的是我使用@RequestBody获取不到数据,如下代码所示:@DatapublicclassBaiduDocNofityResponse{privateStringmessageId;privateStringmessageBody;privateStringnotification;privateStringserver;privateStringsubscriptionName;privateStringversion;privateStringsignature;}@PostMapping("/doc/notify")publicvoidnotify(@RequestBodyBaiduDocNofityResponseresponse){log.info("百度上传文档的回调通知:");log.info(response.toString());//**这里根本没有打印出数据**}但是如果换成下面这段代码就能获取到:@PostMapping("/doc/notify")publicvoidnotify(HttpServletRequestrequest)throwsIOException{log.info("requestcontent-type="+request.getContentType());log.info("百度上传文档的回调通知:"+request.toString());InputStreamis=request.getInputStream();Stringval=StreamUtil.inputStream2String(is,"UTF-8");log.info(val);//**这里能打印出数据**}有谁知道是什么原因吗?
慕村225694
相关分类