还原了错误删除

master
白封羽 2022-06-30 18:07:36 +08:00
parent 51c0e2a1bf
commit 82adc61995
1 changed files with 48 additions and 0 deletions

View File

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