码迷,mamicode.com
首页 > Web开发 > 详细

MVC自定义拦截器Intercepetor

时间:2018-03-08 17:32:41      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:定义   sys   turn   inter   pre   override   ide   port   cep   

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyIntercpetor implements HandlerInterceptor {
//请求执行方法之前执行
    @Override
    public boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler) throws Exception {
        System.out.println("MyIntercpetor.preHandle()");
        return true;
    }
//执行方法之后执行
    @Override
    public void postHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler,
            ModelAndView modelAndView) throws Exception {
        System.out.println("MyIntercpetor.postHandle()");
        
    }
    //最终执行的方法
    @Override
    public void afterCompletion(HttpServletRequest request,
            HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
        System.out.println("MyIntercpetor.afterCompletion()");
        
    }

}

 

MVC自定义拦截器Intercepetor

标签:定义   sys   turn   inter   pre   override   ide   port   cep   

原文地址:https://www.cnblogs.com/BBchao/p/8529005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!