houzhongjian
2024-07-23 a6de490948278991e47952e90671ddba4555e9a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//package com.iailab.module.data.framework.filter;
//
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
//public class MyFilter implements Filter {
//
//    private static final Logger LOGGER = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);
//
//    @Override
//    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
//        LOGGER.info("过滤器filter3开始 doFilter");
//        ServletRequest requestWrapper = null;
//        if(request instanceof HttpServletRequest) {
//            requestWrapper = new MyHttpServletRequestWrapper((HttpServletRequest) request);
//        }
//        //获取请求中的流如何,将取出来的字符串,再次转换成流,然后把它放入到新request对象中。
//        // 在chain.doFiler方法中传递新的request对象
//        if(requestWrapper == null) {
//
//            chain.doFilter(request, response);
//        } else {
//            chain.doFilter(requestWrapper, response);
//        }
//    }
//}