1
13693261870
2022-09-16 fee60c3e25fac0982f3b8cb8feea7225c4ed22f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.terra.proxy.config;
 
import com.terra.proxy.intercepter.ServletInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private ServletInterceptor servletInterceptor;
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(servletInterceptor);
        interceptorRegistration.addPathPatterns("/**");
        interceptorRegistration.excludePathPatterns(  //添加不拦截路径
                "你的登陆路径",         // 登录
                "/**/*.html",            // html静态资源
                "/**/*.js",              // js静态资源
                "/**/*.css",             // css静态资源
                "/**/*.woff",
                "/**/*.ttf",
                "/**/*.ico",
                "/log/**",
                "/**/error*/**"
        );
 
    }
 
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedMethods("*")
                .allowedOrigins("*")
                .allowedHeaders("*");
    }
 
 
}