spring mvc 中如何使用aop拦截到@controller?
spring mvc 中@controller注解在初始化时被代理,请教一下如何使用aop拦截到@controller,有说实现HanlderInterceptorAdapter的,请具体指教一下,新人上路多多关照...
//配置你的拦截器的bean <!-- 日志拦截器 --> <bean id="loggerInterception" class="web.interceptor.LoggerInterception" />//class填写地址 <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <list> <ref bean="loggerInterception"/> </list> </property> </bean> //------------------------分割线----------------------- public class LoggerInterception extends HandlerInterceptorAdapter{ private static Log log = Log.getLog(LoggerInterception.class); @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { // TODO Auto-generated method stub super.afterCompletion(request, response, handler, ex); } @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { log.info("modelAndView:"+modelAndView); super.postHandle(request, response, handler, modelAndView); } @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { log.info("request:"+request.getRequestURI()); return super.preHandle(request, response, handler); } }