标签:order class origin 集成 register add boot reg 需要
@Configuration
public class CorsConfig {
@Bean
public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE); //一定要最高优先级才行,集成OAuth2的时候需要
return bean;
}
}
标签:order class origin 集成 register add boot reg 需要
原文地址:http://www.cnblogs.com/mkxzy/p/7089079.html