34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package cn.bunny.config;
|
|
|
|
import cn.bunny.interceptor.LoginAuthInterceptor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@Component
|
|
public class WebMvcConfiguration implements WebMvcConfigurer {
|
|
@Autowired
|
|
private LoginAuthInterceptor loginAuthInterceptor;
|
|
|
|
// 拦截器注册
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
registry.addInterceptor(loginAuthInterceptor)
|
|
.excludePathPatterns("/admin/system/index/login", "/admin.system/index/generateValidateCode")
|
|
.addPathPatterns("/**");
|
|
}
|
|
|
|
|
|
// 解决跨域
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
registry.addMapping("/**")
|
|
.allowCredentials(true)
|
|
.allowedOriginPatterns("*")
|
|
.allowedMethods("*")
|
|
.allowedHeaders("*");
|
|
}
|
|
}
|