标签:xxx 信息 org port mic family cti code on()
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class CorsConfiguraction {
/**
* 配置跨域请求
* @return
*/
@Bean
public CorsFilter corsFilter() {
//初始化cors配置对象
CorsConfiguration corsConfiguraction = new CorsConfiguration();
//允许跨域的域名
corsConfiguraction.addAllowedOrigin("http://xxx.xxx.com");
//允许cookie
corsConfiguraction.setAllowCredentials(true);
//可跨域的请求方式 如get put,post....
corsConfiguraction.addAllowedMethod("*");
//允许携带任何头信息
corsConfiguraction.addAllowedHeader("*");
//初始化cors配置源对象
UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguraction);
return new CorsFilter(urlBasedCorsConfigurationSource);
}
}
标签:xxx 信息 org port mic family cti code on()
原文地址:https://www.cnblogs.com/Zhusi/p/12358373.html