zoukankan      html  css  js  c++  java
  • springMVC 拦截器

    方案一,(近似)总拦截器,拦截所有url

    <mvc:interceptors>
        <bean class="com.app.mvc.MyInteceptor" />
    </mvc:interceptors>

    为什么叫“近似”,前面说了,Spring没有总的拦截器。

    <mvc:interceptors/>会为每一个HandlerMapping,注入一个拦截器。总有一个HandlerMapping是可以找到处理器的,最多也只找到一个处理器,所以这个拦截器总会被执行的。起到了总拦截器的作用。

    方案二, (近似) 总拦截器, 拦截匹配的URL。

    <mvc:interceptors >  
      <mvc:interceptor>  
            <mvc:mapping path="/user/*" /> <!-- /user/*  -->  
            <bean class="com.mvc.MyInteceptor"></bean>  
        </mvc:interceptor>  
    </mvc:interceptors>  

    就是比 方案一多了一个URL匹配。

  • 相关阅读:
    decltype类型指示符
    vector的使用
    参数使用
    CSPS模拟 43
    CSPS模拟 41
    CSPS模拟 42
    NOIP模拟 40
    NOIP模拟 39
    NOIP模拟 38
    NOIP模拟 37
  • 原文地址:https://www.cnblogs.com/wxwBlog/p/6709109.html
Copyright © 2011-2022 走看看