当前位置: 首页>>代码示例>>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;未经允许,请勿转载。