2019-06-03 springboot 配置拦截器

/**

*

* 自定义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/")

;

}

}

你可能感兴趣的:(2019-06-03 springboot 配置拦截器)