怎麼得到http的返回值,
要得到http的返回值,就要拿到response對象,其中一個是拿到outputstream,然後在res.reset,這種思路是錯誤的,正確的思路是使用wrapper. ContentCachingResponseWrapper是spring實現的wrapper ,
ContentCachingResponseWrapper res=new ContentCachingResponseWrapper(response);
arg2.doFilter(arg0, res);
byte[] body= res.getContentAsByteArray();
arg1.setContentType( res.getContentType() );
arg1.setContentLength( res.getContentSize());
OutputStream oo= arg1.getOutputStream();
oo.write(body);
oo.close();
這裏有一行非常重要 arg1.setContentType( res.getContentType() );之前圖片一直無法顯示,本來以爲沒有獲取數據,後來看了一下有數據,才發現是ContentType,
另外還有一種copy的思路,只是時間有限,無法驗證 .