-->
赞
踩
第一种方式:
1.实现HandlerInterceptor
2.写配置类,WebMvcConfigurerAdapter,同时重写addInterceptors
第二种方式:
<mvc:interceptors>
<!--对所有的请求记性拦截-->
<!--<beans:bean class="com.sunp.common.interceptor.Myinterceptor"/>-->
<!--对特定的请求进行拦截-->
<mvc:interceptor>
<mapping path="/kfc/brands/brand1/*"/>
<beans:bean class="com.sunp.common.interceptor.Myinterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
第三种方式:
实现HandlerInterceptor,使用@component注解,springboot将会自动把该拦截器进行注入
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。