标签:max reg red ati csdn rgs 原创 声明 博文
@SpringBootApplication
public class Application {
private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);//这两句不加不能跨域上传文件,
corsConfiguration.setMaxAge(3600l);//加上去就可以了
return corsConfiguration;
}
/**
* 跨域过滤器
* @return
*/
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig()); // 4
return new CorsFilter(source);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
---------------------
作者:qq_18189595
来源:CSDN
原文:https://blog.csdn.net/qq_18189595/article/details/80136729
版权声明:本文为博主原创文章,转载请附上博文链接!
标签:max reg red ati csdn rgs 原创 声明 博文
原文地址:https://www.cnblogs.com/whb11/p/10104303.html