ContentCachingRequestWrapper类就是为了解决该问题,它将内容放置于缓存中,以供后续获取

@Component
public class RequestCachingFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        filterChain.doFilter(new ContentCachingRequestWrapper(httpServletRequest), httpServletResponse);
    }
}

代码添加后,读取后的Request会自动转为ContentCachingRequestWrapper