MCPcopy Create free account
hub / github.com/LisenCoding/cangku / InterceptorConfig

Class InterceptorConfig

boot/src/main/java/com/config/InterceptorConfig.java:11–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import com.interceptor.AuthorizationInterceptor;
10
11@Configuration
12public class InterceptorConfig extends WebMvcConfigurationSupport{
13
14 @Bean
15 public AuthorizationInterceptor getAuthorizationInterceptor() {
16 return new AuthorizationInterceptor();
17 }
18
19 @Override
20 public void addInterceptors(InterceptorRegistry registry) {
21 registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
22 super.addInterceptors(registry);
23 }
24
25 /**
26 * springboot 2.0配置WebMvcConfigurationSupport之后,会导致默认配置被覆盖,要访问静态资源需要重写addResourceHandlers方法
27 */
28 @Override
29 public void addResourceHandlers(ResourceHandlerRegistry registry) {
30 registry.addResourceHandler("/**")
31 .addResourceLocations("classpath:/resources/")
32 .addResourceLocations("classpath:/static/")
33 .addResourceLocations("classpath:/admin/")
34 .addResourceLocations("classpath:/img/")
35 .addResourceLocations("classpath:/front/")
36 .addResourceLocations("classpath:/public/");
37 super.addResourceHandlers(registry);
38 }
39}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected