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("*");
|
}
|
|
|
}
|