springmvc 对请求进行拦截

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/ spring-beans-3.2.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-3.2.xsd
     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
    
     <mvc:interceptors>
        <!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
        <bean class="com.inteceptor.AllInteceptor"/>
        <mvc:interceptor>
            <mvc:mapping path="/**"/>           
            <!-- 需排除拦截的地址 --> 
            <mvc:exclude-mapping path="/" />
           <mvc:exclude-mapping path="/test" />
            <!-- 定义在mvc:interceptor下面的表示是对特定的请求才进行拦截的 -->
            <bean class="com.inteceptor.TimeInteceptor"/>
        </mvc:interceptor>
    </mvc:interceptors>
    
</beans>

<mvc:exclude-mapping path="/test" /> 3.2才有,3.2以下没有

你可能感兴趣的:(springMVC)