WebMvcConfiugrationAdaper!
该jar包好像是不能用了,在做CORS跨域访问
@Configuration
public class SimpleCORS
{
/**
private CorsConfiguration buildConfig()
{
CorsConfiguration corsConfiguration = new CorsConfiguration();
// 允许跨域访问的域名
corsConfiguration.addAllowedOrigin("*");
// 请求头
corsConfiguration.addAllowedHeader("*");
// 请求方法
corsConfiguration.addAllowedMethod(HttpMethod.DELETE);
corsConfiguration.addAllowedMethod(HttpMethod.POST);
corsConfiguration.addAllowedMethod(HttpMethod.GET);
corsConfiguration.addAllowedMethod(HttpMethod.PUT);
corsConfiguration.addAllowedMethod(HttpMethod.DELETE);
corsConfiguration.addAllowedMethod(HttpMethod.OPTIONS);
// 预检请求的有效期,单位为秒。
corsConfiguration.setMaxAge(3600L);
// 是否支持安全证书
corsConfiguration.setAllowCredentials(true);
return corsConfiguration;
}
}