catch405

 

SpringBoot使用拦截器 Interceptor

1.创建一个拦截器对象,实现HandlerInterceptor接口,重写preHandle方法,并在方法中定义拦截规则

2.创建一个控制层

3.在 项 目 中 创 建 一 个 config 包 , 创 建 一 个 配 置 类 InterceptorConfig , 并 实 现 WebMvcConfigurer 接口, 覆盖接口中的 addInterceptors 方法,并为该配置类添加
@Configuration 注解,标注此类为一个配置类

posted on 2020-12-09 10:02  catch405  阅读(72)  评论(0)    收藏  举报

导航