Spring 3.0.5 MVC 基于注解的拦截器

[i]org.springframework.web.servlet.handler.HandlerInterceptorAdapter[/i]实现此方法,里面有三个拦截点,可Override实现自己的内容

1、[i]public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception;[/i]

Controller方法执行前执行此方法,返回的boolean控制拦截器链是否继续执行

2、[i]public void postHandle(
HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws Exception;[/i]

Controller方法执行后,将进入到这里,能处理ModelAndView哦

3、[i]public void afterCompletion(
HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception;[/i]

输出页面执行后进入到这里,能获得Exception了

[b]springmvc.xml[/b]








OK,就这么简单

你可能感兴趣的:(java,MVC,Spring,XML,Servlet,Web)