zoukankan      html  css  js  c++  java
  • 配置类Configuration怎样使用

    public class CorsConfiguration {

    /**
    * Wildcard representing <em>all</em> origins, methods, or headers.
    */
    public static final String ALL = "*";

    private static final List<HttpMethod> DEFAULT_METHODS;

    static {
    List<HttpMethod> rawMethods = new ArrayList<HttpMethod>(2);
    rawMethods.add(HttpMethod.GET);
    rawMethods.add(HttpMethod.HEAD);
    DEFAULT_METHODS = Collections.unmodifiableList(rawMethods);
    }


    private List<String> allowedOrigins;

    private List<String> allowedMethods;

    private List<HttpMethod> resolvedMethods = DEFAULT_METHODS;

    private List<String> allowedHeaders;

    private List<String> exposedHeaders;

    private Boolean allowCredentials;

    private Long maxAge;


    /**
    * Construct a new {@code CorsConfiguration} instance with no cross-origin
    * requests allowed for any origin by default.
    * @see #applyPermitDefaultValues()
    */
    public CorsConfiguration() {
    }

    /**
    * Construct a new {@code CorsConfiguration} instance by copying all
    * values from the supplied {@code CorsConfiguration}.
    */
    public CorsConfiguration(CorsConfiguration other) {
    this.allowedOrigins = other.allowedOrigins;
    this.allowedMethods = other.allowedMethods;
    this.resolvedMethods = other.resolvedMethods;
    this.allowedHeaders = other.allowedHeaders;
    this.exposedHeaders = other.exposedHeaders;
    this.allowCredentials = other.allowCredentials;
    this.maxAge = other.maxAge;
    }


    /**
    Set<String> combined = new LinkedHashSet<String>(source);
    return new ArrayList<String>(combined);
    * Set the origins to allow, e.g. {@code "http://domain1.com"}.
    * <p>The special value {@code "*"} allows all domains.
    * <p>By default this is not set.
    */
    public void setAllowedOrigins(List<String> allowedOrigins) {
    this.allowedOrigins = (allowedOrigins != null ? new ArrayList<String>(allowedOrigins) : null);
    }

  • 相关阅读:
    操作 Java 数组的 12 个最佳方法
    详解 JavaScript 中 splice() 方法
    Java 读取 .properties 配置文件的几种方式
    表单中单选、多选、选择框值的获取及表单的序列化
    一个调出上下文菜单的实例
    跨浏览器的事件侦听器和事件对象
    动态加载js和css
    php语言实现的7种基本的排序方法
    CORS(跨源资源共享)实战
    ubuntu中LAMP环境搭建及ubuntu语言和输入法设置
  • 原文地址:https://www.cnblogs.com/panxuejun/p/7274947.html
Copyright © 2011-2022 走看看