2019-06-03 springboot 配置拦截器

2019-06-03  本文已影响0人  zz云飞扬

/**

*

* 自定义Spring mvc配置

*

*/

@Configuration

public class WebMvcConfig

extends WebMvcConfigurerAdapter {

@Bean

    public RuseridInterceptor getRuseridInterceptor() {

return new RuseridInterceptor();

}

/**

* 定义拦截器

    * @param registry

    */

    @Override

    public void addInterceptors(InterceptorRegistry registry) {

registry.addInterceptor(getRuseridInterceptor())

.addPathPatterns("/aaa/public","/bbb/public","/ccc/public")

//  .excludePathPatterns("/static/**","/error/**")

      ;

}

@Override

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler("/static/**")

.addResourceLocations("classpath:/META-INF/resources/")

.addResourceLocations("classpath:/resources/")

.addResourceLocations("classpath:/static/")

.addResourceLocations("classpath:/public/")

;

}

}

上一篇 下一篇

猜你喜欢

热点阅读