springboot(11)_拦截器

自定义Intercepter

  • 启动类里面增加 @ServletComponentScan,进行扫描
  • 新建一个MyWebMvcConfigurer类,implements WebMvcConfigurer,并实现对应的接口
  • 在addInterceptors方法注册拦截器
registry.addInterceptor(new OneIntercepter()).addPathPatterns("/api2/*/**");
  • 自定义过滤器OneIntercepter类 implements HandlerInterceptor,并实现对应的接口

猜你喜欢

转载自www.cnblogs.com/xeclass/p/12640131.html
今日推荐