Spring mvc:interceptors 探究

使用实例:

	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/**.html" />
			<mvc:exclude-mapping path="/assets/" />
			<bean class="com.imserver.framework.web.AuthorityInterceptor" />
		</mvc:interceptor>
		<bean class="com.imserver.framework.web.AuthorityInterceptor" />
		<ref bean="viewResolver"/>
	</mvc:interceptors>
  

  

interceptors 元素只能包含 interceptor、bean 和 ref。 bean 和 ref 指向的类需要实现 HandlerInterceptor 接口,或者继承HandlerInterceptorAdapter 类重写自己关心的某个方法。
interceptor 元素包含mapping、exclude-mapping、bean, 必须包含bean。
path 匹配:
  • 必须以 / 开头
  • ** 表示多级目录
  • * 表示任意

原文地址:https://www.cnblogs.com/baozixiaopu/p/9547465.html