• spring拦截器


     
    <!--     将拦截所有请求 -->
    <!--     <mvc:interceptors> -->
    <!--         <bean class="com.SpringInter"></bean> -->
    <!--     </mvc:interceptors> -->
        
        
    <!--     针对具体路径进行拦截 -->
        <mvc:interceptors>
            <mvc:interceptor>
                <mvc:mapping path="/test"/>
                <bean class="com.SpringInter"></bean>
            </mvc:interceptor>
        </mvc:interceptors>
    package com;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.web.servlet.HandlerInterceptor;
    import org.springframework.web.servlet.ModelAndView;
    
    public class SpringInter implements HandlerInterceptor {
    
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
                throws Exception {
            String url=request.getRequestURI();
            System.out.println(url);
            return true;
        }
    
        public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                ModelAndView modelAndView) throws Exception {
    
        }
    
        public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
                throws Exception {
    
        }
    
    }

    个人公众号:益起走

    hi

  • 相关阅读:
    Linux常用命令1
    Linux常用命令
    java的接口和抽象类区别
    字符串的全排列
    字符串的全组合
    Mysql范式
    同步 异步 阻塞 非阻塞概念区分
    死锁产生的条件以及解决方法
    Mysql存储引擎MyIsAM和InnoDB区别
    SLES documentation
  • 原文地址:https://www.cnblogs.com/javaweb2/p/6610885.html
Copyright © 2020-2023  润新知