當前位置: 首頁>>代碼示例>>Java>>正文


Java CorsConfiguration.addAllowedHeader方法代碼示例

本文整理匯總了Java中org.springframework.web.cors.CorsConfiguration.addAllowedHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java CorsConfiguration.addAllowedHeader方法的具體用法?Java CorsConfiguration.addAllowedHeader怎麽用?Java CorsConfiguration.addAllowedHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.cors.CorsConfiguration的用法示例。


在下文中一共展示了CorsConfiguration.addAllowedHeader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: filterRegistrationBean

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();

    final CorsConfiguration corsConfiguration = new CorsConfiguration();
    corsConfiguration.setAllowCredentials(corsSupportProperties.isAllowCredentials());
    corsConfiguration.addAllowedOrigin(corsSupportProperties.getAllowOrigin());
    corsConfiguration.addAllowedHeader(corsSupportProperties.getAllowHeader());
    corsConfiguration.addAllowedMethod(corsSupportProperties.getAllowMethod());

    urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);

    CorsFilter corsFilter = new CorsFilter(urlBasedCorsConfigurationSource);
    FilterRegistrationBean registration = new FilterRegistrationBean(corsFilter);
    registration.addUrlPatterns("/*");
    registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return registration;
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:19,代碼來源:CorsSupportConfiguration.java

示例2: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();

    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");

    config.addExposedHeader("WWW-Authenticate");
    config.addExposedHeader("Access-Control-Allow-Origin");
    config.addExposedHeader("Access-Control-Allow-Headers");

    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);

    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
開發者ID:evoila,項目名稱:cfsummiteu2017,代碼行數:27,代碼來源:BaseConfiguration.java

示例3: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    // return new CorsFilter(source);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
開發者ID:lorderikir,項目名稱:googlecloud-techtalk,代碼行數:21,代碼來源:CorsConfig.java

示例4: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public CorsFilter corsFilter() {

    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    final CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);

    // TODO - Lock down to specific host in Prod
    config.addAllowedOrigin("*");
    //config.addAllowedOrigin("http://localhost:3000");

    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("DELETE");
    source.registerCorsConfiguration("/**", config);
    return new CorsFilter(source);
}
 
開發者ID:gazbert,項目名稱:bxbot-ui-server,代碼行數:21,代碼來源:RestCorsConfig.java

示例5: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
開發者ID:fku233,項目名稱:Plum,代碼行數:20,代碼來源:CorsConfig.java

示例6: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
    // setup origin url
    String origin = corsProperties.getHost() + ":" +
                    corsProperties.getPort();

    // setup cors config
    CorsConfiguration corsConfig = new CorsConfiguration();
    corsConfig.setAllowCredentials(true);
    corsConfig.addAllowedOrigin(origin);
    corsConfig.addAllowedHeader("*");
    corsConfig.addAllowedMethod("*");

    // setup source
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/api/**", corsConfig);
    FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);

    return bean;
}
 
開發者ID:rvep,項目名稱:dev_backend,代碼行數:22,代碼來源:CorsFilterRegistration.java

示例7: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
/**
 * Enables CORS
 *
 * @return
 */
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(0);
    return bean;
}
 
開發者ID:jiaweizhang,項目名稱:spotify-pull-requests,代碼行數:25,代碼來源:Application.java

示例8: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);

    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return bean;
}
 
開發者ID:sys-devel-d,項目名稱:pimp,代碼行數:21,代碼來源:SecurityConfig.java

示例9: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
/**
 *
 * @return
 */
@Bean
public CorsFilter corsFilter() {
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    final CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("HEAD");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("DELETE");
    config.addAllowedMethod("PATCH");
    source.registerCorsConfiguration("/**", config);
    return new CorsFilter(source);
}
 
開發者ID:PacktPublishing,項目名稱:Microservices-Building-Scalable-Software,代碼行數:22,代碼來源:EdgeApp.java

示例10: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
/**
 * Enables CORS
 *
 * @return
 */
@Bean
public FilterRegistrationBean corsFilter() {
	UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
	CorsConfiguration config = new CorsConfiguration();
	config.setAllowCredentials(true);
	config.addAllowedOrigin("*");
	config.addAllowedHeader("*");
	config.addAllowedMethod("OPTIONS");
	config.addAllowedMethod("HEAD");
	config.addAllowedMethod("GET");
	config.addAllowedMethod("PUT");
	config.addAllowedMethod("POST");
	config.addAllowedMethod("DELETE");
	config.addAllowedMethod("PATCH");
	source.registerCorsConfiguration("/**", config);
	final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
	bean.setOrder(0);
	return bean;
}
 
開發者ID:jiaweizhang,項目名稱:assimulator,代碼行數:25,代碼來源:Application.java

示例11: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public CorsFilter corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("DELETE");
    source.registerCorsConfiguration("/**", config);
    return new CorsFilter(source);
}
 
開發者ID:Code4SocialGood,項目名稱:C4SG-Obsolete,代碼行數:16,代碼來源:RestConfig.java

示例12: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@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);
	return bean;
}
 
開發者ID:MinsxCloud,項目名稱:minsx-framework,代碼行數:14,代碼來源:ResourceServerConfig.java

示例13: buildConfig

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
/**
 允許任何域名使用
 允許任何頭
 允許任何方法(post、get等)
 */
private CorsConfiguration buildConfig() {
    CorsConfiguration corsConfiguration = new CorsConfiguration();
    corsConfiguration.addAllowedOrigin("*"); // 1
    corsConfiguration.addAllowedHeader("*"); // 2
    corsConfiguration.addAllowedMethod("*"); // 3
    return corsConfiguration;
}
 
開發者ID:BekeyChao,項目名稱:spring-vue-demo,代碼行數:13,代碼來源:CorsConfig.java

示例14: corsFilter

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
@Bean
public FilterRegistrationBean corsFilter() {
	final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
	CorsConfiguration config = new CorsConfiguration();
	config.setAllowCredentials(true);
	config.addAllowedOrigin("*"); // @Value: http://localhost:8080
	config.addAllowedHeader("*");
	config.addAllowedMethod("*");
	source.registerCorsConfiguration("/**", config);
	FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
	bean.setOrder(0);
	return bean;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:14,代碼來源:CorsConfig.java

示例15: filterRegistrationBean

import org.springframework.web.cors.CorsConfiguration; //導入方法依賴的package包/類
/**
 * CORS Filter
 *
 * @return Filter
 */
@Bean
public FilterRegistrationBean filterRegistrationBean() {
    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);
    return bean;
}
 
開發者ID:apssouza22,項目名稱:java-microservice,代碼行數:19,代碼來源:OAuth2ServerConfiguration.java


注:本文中的org.springframework.web.cors.CorsConfiguration.addAllowedHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。