- //实现handlerInterceptor 接口
- public class MyInterceptor implements HandlerInterceptor{
-
- @Override
- public
boolean
preHandle(HttpServletRequest request,
- HttpServletResponse response, Object handler)
throws Exception {
- System.out.println("prehandle拦截请求");
- return true;
- //true 全部通过 false全部拦截
- }
-
- @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 渲染请求 "); }
-
- }
|