springMVC常用注解/标签

发布时间 2023-05-23 19:01:27作者: 邵杠杠

 

 

 

配置拦截器

方式一:

    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**"/> <!-- 生效范围/**代表所有 -->
            <mvc:exclude-mapping path="/testRequestEntity"/> <!-- 不生效的范围-->
            <ref bean="fistInterceptor"></ref><!-- 使用哪个拦截器拦截 -->
        </mvc:interceptor>
    </mvc:interceptors>

  

方式二:

<mvc:interceptors>-->
    <bean class="com.atguigu.mvc.interceptors.FistInterceptor"></bean>对所有请求生效
</mvc:interceptors>-->

 

方式三:

<mvc:interceptors>-->
    <ref bean="fistInterceptor"></ref>
</mvc:interceptors>-->

  

方式二和方式三两种配置方式都是对DispatcherServlet所处理的所有的请求进行拦截