-->
当前位置:   article > 正文

spring boot 配置拦截器_springboot配置拦截器

springboot配置拦截器

第一种方式:

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将会自动把该拦截器进行注入

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/716349
推荐阅读
相关标签
  

闽ICP备14008679号