0
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
StringWriter writer = new StringWriter();
IOUtils.copy(request.getInputStream(), writer, "UTF-8");
rawRequest = writer.toString();
System.out.println("raw Request :" + rawRequest);
chain.doFilter(req, res);
}
当我运行它,我得到正确格式的原始请求字符串,但是当我试图在任何地方得到这个原始请求doFilter方法之外,它返回null。如何获得Spring MVC中的外部过滤字符串
有没有一种方法可以在doFilter方法之外获得此String。我试图将这个字符串传递给一个新的方法,但没有任何作用
可能重复[如何读取request.getInputStream()多次](https://stackoverflow.com/questions/4449096/how-to-read-request-getinputstream-multiple-times) – alfcope
你是什么意思将它传递给一个新的方法?显示更多代码.. –