美文网首页
1 执行的先后顺序

1 执行的先后顺序

作者: 云淡风轻任我行 | 来源:发表于2023-06-06 00:17 被阅读0次
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("before...");
        chain.doFilter(request, response);
        System.out.println("after...");
    }
    
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
            System.out.println("preHandle");
            return true;
        }
    
        @Override
        public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
            System.out.println("postHandle");
        }
    
        @Override
        public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
            System.out.println("afterCompletion");
        }
    
    • 执行的先后顺序

    • System.out.println("before...");

    • preHandle()

    • chain.doFilter(request, response);

      • Servlet的doService()方法
    • postHandle()

    • afterCompletion()

    • System.out.println("after...");

    image.png

    相关文章

      网友评论

          本文标题:1 执行的先后顺序

          本文链接:https://www.haomeiwen.com/subject/zogwedtx.html