支付回调无法或IO数据流,是否拦截器提前读取了IO流数据?

Blade 已结 1 1267
feelove
feelove 剑圣 2019-11-18 11:32
悬赏:10

一、该问题的重现步骤是什么?

1. 支付成功后,需要向后台发送回调通知,格式XML,需要在request ,IO流中获取

2. 配置xss放行之后,依然为空

3.因为request流数据只能读取一次,是否在这之前系统拦截器,提前读取了IO数据流?

下面为处理请求的代码,读书数据为空

@PostMapping(value = "/payNotify")
public String payNotify(HttpServletRequest request) throws IOException {

   InputStream inStream = request.getInputStream();
   ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
   byte[] buffer = new byte[1024];
   int len = 0;
   while ((len = inStream.read(buffer)) != -1) {
      outSteam.write(buffer, 0, len);
   }
   String resultxml = new String(outSteam.toByteArray(), "utf-8");

   outSteam.close();
   inStream.close();

   System.out.println("========================="+resultxml);
   return null;
}


1条回答
提交回复