拦截器
一、拦截器的配置
SpringMVC中的拦截器用于拦截控制器方法的执行
SpringMVC中的拦截器需要实现HandlerInterceptor
SpringMVC的拦截器必须在SpringMVC的配置文件中进行配置:
<!--配置拦截器-->
<mvc:interceptors>
<!--<bean class="com.oykq.interceptors.FirstInterceptor"></bean>-->
<!--<ref bean="firstInterceptor"></ref>-->
<!-- 以上两种配置方式都是对DispatcherServlet所处理的所有的请求进行拦截 -->
<mvc:interceptor>
<mvc:mapping path="/*"/> <!--拦截所有/**-->
<mvc:exclude-mapping path="/" />
<ref bean="firstInterceptor"></ref>
</mvc:interceptor>
</mvc:interceptors>
<!--
以上配置方式可以通过ref或bean标签设置拦截器,通过mvc:mapping设置需要拦截的请求,通过mvc:exclude-mapping设置需要排除的请求,即不需要拦截的请求
-->
拦截器
@Compon