java.lang.IllegalStateException: getReader() has already been called for this request

后端 未结 4 636
孤街浪徒
孤街浪徒 2020-12-29 04:12

I want to add logging to my Servlet, so I\'ve created Filter which should display request and go to the Servlet. But unfortunately I\'ve encoutered exception:



        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 04:50

    Use ContentCachingRequestWrapper class. Wrap HttpServletRequest in thi will resolve issue

    Sample : if you want to convert your "HttpServletRequest servletRequest" you can do some thing like

    import org.springframework.web.util.ContentCachingRequestWrapper;
    
    ContentCachingRequestWrapper request = new ContentCachingRequestWrapper(servletRequest);
    

    Hope it helps!!!

提交回复
热议问题