<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.6</version>
</dependency>
@Configuration
public class CorsConfig {
@Bean
public FilterRegistrationBean corsFilter() {
Properties props = new Properties();
props.setProperty("cors.allowGenericHttpRequests", "true");
props.setProperty("cors.allowOrigin", "*");
props.setProperty("cors.allowSubdomains", "true");
props.setProperty("cors.supportedMethods", "GET, HEAD, POST, OPTIONS");
props.setProperty("cors.supportedHeaders", "*");
props.setProperty("cors.supportsCredentials", "true");
props.setProperty("cors.maxAge", "3600");
CORSConfiguration config = null;
try {
config = new CORSConfiguration(props);
} catch (CORSConfigurationException e) {
e.printStackTrace();
}
FilterRegistrationBean bean = new FilterRegistrationBean(new CORSFilter(config));
bean.setOrder(0);
return bean;
}
}
分享到:
相关推荐
js跨域解决方案
前后端分离H5 跨域解决方案 提供多种解决方法 详情请下载文件 自己看 100%可以解决你的问题
Spring,跨域 ,解决方案,官方, demo,cros
前端跨域解决方案,jsonp和cros两种解决方式。我们发现,Web页面上调用js文件时不受是否跨域的影响,凡是拥有"src"这个属性的标签都拥有跨域的能力,比如[removed]、、<iframe>。那就是说如果要跨域访问数据,...
主要介绍了前端常见跨域解决方案的相关内容,包括对跨域的解释,常见跨域场景以及跨域解决方案,内容丰富,需要的朋友可以参考下。
前端跨域原理以及跨域解决方案.docx
1.文件夹SilverlightFrmWcf : winform程序托管wcf服务Silverlight调用wcf 跨域解决方案 (1)解决方案frmWcfService:winform程序托管wcf服务 (2)Silverlight项目调用wcf解决方案 2.文件夹SilverlightWCFDemo: iis...
分享转载:前端常见跨域解决方案 1、 通过jsonp跨域 2、 document.domain + iframe跨域 3、 location.hash + iframe 4、 window.name + iframe跨域 5、 postMessage跨域 6、 跨域资源共享(CORS) 7、 nginx...
web跨域解决方案.docx
js跨域解决方案.docx
解决tomcat在IP 和端口不同时引起的跨域问题,解决方案,通过编写crossDomain.xml文件
跨域解决方案整理笔记.docx
SpringMVC的跨域解决方案.docx
10种跨域解决方案.docx
同源策略和跨域解决方案.docx
解决ajax跨域Java解决方案,通过代理实现ajax跨域操作,避免拒绝访问等跨域操作问题
什么是跨域解决方案有哪些.docx
SpringMvc的跨域解决方案_2.docx
跨域访问解决方案,关于跨域访问cookie的资料
跨域解决方案介绍2,转自github..docx