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


Java CorsRegistry類代碼示例

本文整理匯總了Java中org.springframework.web.servlet.config.annotation.CorsRegistry的典型用法代碼示例。如果您正苦於以下問題:Java CorsRegistry類的具體用法?Java CorsRegistry怎麽用?Java CorsRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/**").allowedOrigins("*")
                    .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
                    .allowCredentials(false).maxAge(3600);
        }
    };
}
 
開發者ID:DigAg,項目名稱:digag-server,代碼行數:12,代碼來源:WebSecurityConfig.java

示例2: addCorsMappings

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
/**
 * cors跨域處理
 *
 * @param registry
 */
@Override
public void addCorsMappings ( CorsRegistry registry ) {
	registry.addMapping( "/**" )
			.allowedMethods(
				HttpMethod.HEAD.name() ,
				HttpMethod.GET.name() ,
				HttpMethod.POST.name() ,
				HttpMethod.PUT.name() ,
				HttpMethod.DELETE.name() ,
				HttpMethod.OPTIONS.name() ,
				HttpMethod.PATCH.name() ,
				HttpMethod.TRACE.name()
			)
			// 允許的域名
			.allowedOrigins( "*" );
}
 
開發者ID:yujunhao8831,項目名稱:spring-boot-start-current,代碼行數:22,代碼來源:SpringConfig.java

示例3: addCorsMappings

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Override
public final void addCorsMappings(final CorsRegistry registry) {
    registry.addMapping("/**")
            .allowedOrigins("*")
            .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
            .allowedHeaders(
                    "Host",
                    "User-Agent",
                    "X-Requested-With",
                    "Accept",
                    "Accept-Language",
                    "Accept-Encoding",
                    "Authorization",
                    "Referer",
                    "Connection",
                    "Content-Type")
            .exposedHeaders("header1", "header2")
            .maxAge(MAX_AGE)
            .allowCredentials(true);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:21,代碼來源:WebConfiguratie.java

示例4: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/")
                    .allowedOrigins("*")
                    .allowedMethods("POST, GET, OPTIONS, DELETE ,PUT")
                    .allowedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER,
                            AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, AC_ALLOW_CREDENTIALS_HEADER, XXSRFTOKEN, XXSRFTOKEN2)
                    .exposedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER,
                            AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, XXSRFTOKEN, XXSRFTOKEN2)
                    .allowCredentials(true).maxAge(3600);
        }
    };
}
 
開發者ID:lordoftheflies,項目名稱:wonderjameeee,代碼行數:17,代碼來源:SecurityConfiguration.java

示例5: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
/**
 * Spring4 Cors filter
 *  By default disabled
 * @return
 */
@Bean
@ConditionalOnProperty(value="appverse.frontfacade.rest.cors.enabled", matchIfMissing=false)
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            String path = apiPath;
            if (!StringUtils.isEmpty(corsPath)){
                path = corsPath;
            }
            registry.addMapping(path + "/**")
                    .allowedOrigins(StringUtils.commaDelimitedListToStringArray(allowedOrigins))
                    .allowedMethods(StringUtils.commaDelimitedListToStringArray(allowedMethods))
                    .allowedHeaders(StringUtils.commaDelimitedListToStringArray(allowedHeaders))
                    .allowCredentials(Boolean.valueOf(allowedCredentials))
                    .maxAge(Long.valueOf(maxAge));
        }
    };
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:25,代碼來源:FrontFacadeRestAutoConfiguration.java

示例6: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer()
{
	return new WebMvcConfigurerAdapter() {
		@Override
		public void addCorsMappings(CorsRegistry registry)
		{
			registry.addMapping("/swagger/swagger-spec.yaml");
			if (yonaProperties.getSecurity().isCorsAllowed())
			{
				// Enable CORS for the other resources, to allow testing the API through Swagger UI.
				registry.addMapping("/**").allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE");
			}
		}
	};
}
 
開發者ID:yonadev,項目名稱:yona-server,代碼行數:17,代碼來源:AppServiceApplication.java

示例7: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {

        @Override
        public void addCorsMappings(CorsRegistry registry) {
            // Add CORS header for all path in application
            registry.addMapping("/**") //
                    .allowedOrigins("*") //
                    .allowedMethods("POST", "GET", "OPTIONS", "DELETE", "PUT", "PATCH") //
                    .maxAge(3600) //
                    .allowedHeaders("x-requested-with", "Content-Type", "accept", "Authorization")
                    .exposedHeaders("Authorization")
                    .allowCredentials(true);
        }
    };
}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:18,代碼來源:CORSConfiguration.java

示例8: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
@SuppressWarnings("AnonymousInnerClassMayBeStatic")
public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/v1/**")
                    .allowCredentials(true)
                    .allowedOrigins(Constants.UrlConstants.ALLOWED_ORIGINS)
                    .allowedMethods("GET", "HEAD", "POST", "PATCH", "DELETE", "OPTIONS");
        }
    };
}
 
開發者ID:java-park-mail-ru,項目名稱:SpaceInvasion-09-2017,代碼行數:14,代碼來源:SpaceInvasion.java

示例9: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
/**
 * Activation de CORS pour tous les domaines.
 * 
 * @return Configurateur Spring MVC.
 */
@Bean
public WebMvcConfigurer corsConfigurer() {
	return new WebMvcConfigurerAdapter() {
		@Override
		public void addCorsMappings(CorsRegistry registry) {

			registry.addMapping("/**").allowedOrigins("*");

		}
	};
}
 
開發者ID:DTAFormation,項目名稱:112016.pizzeria-app,代碼行數:17,代碼來源:PizzeriaApp.java

示例10: addCorsMappings

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Override
public void addCorsMappings(CorsRegistry registry) {
    registry.addMapping("/**")
            .allowedHeaders("*")
            .allowedMethods("*")
            .allowedOrigins("*");
}
 
開發者ID:yuexine,項目名稱:loafer,代碼行數:8,代碼來源:WebConfiguration.java

示例11: addCorsMappings

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Override
public void addCorsMappings(CorsRegistry registry) {
    registry.addMapping("/**")
            .allowedOrigins(crossMapping)
            .allowedMethods("GET","POST","PUT", "DELETE", "OPTIONS")
            .allowedHeaders("*")
            .allowCredentials(true)
            .maxAge(3600);
}
 
開發者ID:lemon-china,項目名稱:lemon-fileservice,代碼行數:10,代碼來源:SpringConfiguration.java

示例12: mvcConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer mvcConfigurer() {
    return new WebMvcConfigurerAdapter() {
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/**").allowedMethods("GET", "PUT", "POST", "GET", "OPTIONS");
        }
    };
}
 
開發者ID:lorderikir,項目名稱:googlecloud-techtalk,代碼行數:9,代碼來源:CorsConfig.java

示例13: corsConfiguration

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfiguration() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addCorsMappings(CorsRegistry registry) {
            registry.addMapping("/api/**")
                    .allowedMethods(HttpMethod.GET.toString(), HttpMethod.POST.toString(),
                            HttpMethod.PUT.toString(), HttpMethod.DELETE.toString(), HttpMethod.OPTIONS.toString())
                    .allowedOrigins("*");
        }
    };
}
 
開發者ID:redhat-developer-demos,項目名稱:istio-ola,代碼行數:13,代碼來源:KeycloakCORSConfiguration.java

示例14: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
	return new WebMvcConfigurerAdapter() {
		@Override
		public void addCorsMappings(CorsRegistry registry) {
			registry.addMapping("/**").allowedOrigins("*");
		}
	};
}
 
開發者ID:Taskana,項目名稱:taskana,代碼行數:10,代碼來源:WebSecurityConfig.java

示例15: corsConfigurer

import org.springframework.web.servlet.config.annotation.CorsRegistry; //導入依賴的package包/類
@Bean
public WebMvcConfigurer corsConfigurer() {
  return new WebMvcConfigurerAdapter() {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
      registry.addMapping("/**").allowedOrigins("http://localhost:4200");
    }
  };
}
 
開發者ID:iorga-group,項目名稱:debattons,代碼行數:10,代碼來源:ApiServerApplication.java


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