一、HandlerInterceptor 用法
第一步:注册拦截器
<!-- 注册拦截器 --> <mvc:interceptors> <bean class="com.project.base.interceptor.ControlInterceptor" /> </mvc:interceptors>
第二步:继承HandlerInterceptor ,实现拦截器
public class ControlInterceptor implements HandlerInterceptor{ private static Logger logger = Logger.getLogger(ControlInterceptor.class); /** * 执行完控制器后调用,即离开时 */ @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3) throws Exception { logger.info("className--->" + arg2); logger.info("request--->" + request); }}
时间: 2024-10-12 10:40:16