类 ResponseCookie

    • 方法详细资料

      • getMaxAge

        public Duration getMaxAge()
        Return the cookie "Max-Age" attribute in seconds.

        A positive value indicates when the cookie expires relative to the current time. A value of 0 means the cookie should expire immediately. A negative value means no "Max-Age" attribute in which case the cookie is removed when the browser is closed.

      • isSecure

        public boolean isSecure()
        Return true if the cookie has the "Secure" attribute.
      • getSameSite

        @Nullable
        public String getSameSite()
        Return the cookie "SameSite" attribute, or null if not set.

        This limits the scope of the cookie such that it will only be attached to same site requests if "Strict" or cross-site requests if "Lax".

        从以下版本开始:
        5.1
        另请参阅:
        RFC6265 bis
      • from

        public static ResponseCookie.ResponseCookieBuilder from​(String name,
                                                                String value)
        Factory method to obtain a builder for a server-defined cookie that starts with a name-value pair and may also include attributes.
        参数:
        name - the cookie name
        value - the cookie value
        返回:
        a builder to create the cookie with
      • fromClientResponse

        public static ResponseCookie.ResponseCookieBuilder fromClientResponse​(String name,
                                                                              String value)
        Factory method to obtain a builder for a server-defined cookie. Unlike from(String, String) this option assumes input from a remote server, which can be handled more leniently, e.g. ignoring a empty domain name with double quotes.
        参数:
        name - the cookie name
        value - the cookie value
        返回:
        a builder to create the cookie with
        从以下版本开始:
        5.2.5