还原了错误删除
parent
51c0e2a1bf
commit
82adc61995
|
@ -0,0 +1,48 @@
|
||||||
|
package cn.edu.hfut.rmdjzz.projectmanagement.config;
|
||||||
|
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.interceptor.CorsInterceptor;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.interceptor.TokenInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 张韬
|
||||||
|
* created at 2022/6/28 19:44
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
@Bean
|
||||||
|
public CorsInterceptor getCorsInterceptor() {
|
||||||
|
return new CorsInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TokenInterceptor getTokenInterceptor() {
|
||||||
|
return new TokenInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(getCorsInterceptor()).addPathPatterns("/**");
|
||||||
|
registry.addInterceptor(getTokenInterceptor())
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/staff/login")
|
||||||
|
.excludePathPatterns("/hello")
|
||||||
|
.excludePathPatterns("/error")
|
||||||
|
.excludePathPatterns("/staff/timetest");
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/**")
|
||||||
|
.allowedOriginPatterns("*")
|
||||||
|
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
|
||||||
|
.allowedHeaders("token")
|
||||||
|
.allowCredentials(true)
|
||||||
|
.maxAge(3600)
|
||||||
|
.allowedHeaders("*");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in New Issue