类 ResponseCookie
- java.lang.Object
- org.springframework.http.HttpCookie
- org.springframework.http.ResponseCookie
public final class ResponseCookie extends HttpCookie
AnHttpCookie
subclass with the additional attributes allowed in the "Set-Cookie" response header. To build an instance use thefrom(java.lang.String, java.lang.String)
static method.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel
- 另请参阅:
- RFC 6265
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
ResponseCookie.ResponseCookieBuilder
A builder for a server-defined HttpCookie with attributes.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
equals(Object other)
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.static ResponseCookie.ResponseCookieBuilder
fromClientResponse(String name, String value)
Factory method to obtain a builder for a server-defined cookie.String
getDomain()
Return the cookie "Domain" attribute, ornull
if not set.Duration
getMaxAge()
Return the cookie "Max-Age" attribute in seconds.String
getPath()
Return the cookie "Path" attribute, ornull
if not set.String
getSameSite()
Return the cookie "SameSite" attribute, ornull
if not set.int
hashCode()
boolean
isHttpOnly()
Returntrue
if the cookie has the "HttpOnly" attribute.boolean
isSecure()
Returntrue
if the cookie has the "Secure" attribute.String
toString()
从类继承的方法 org.springframework.http.HttpCookie
getName, getValue
方法详细资料
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.
getDomain
@Nullable public String getDomain()
Return the cookie "Domain" attribute, ornull
if not set.
isSecure
public boolean isSecure()
Returntrue
if the cookie has the "Secure" attribute.
isHttpOnly
public boolean isHttpOnly()
Returntrue
if the cookie has the "HttpOnly" attribute.
getSameSite
@Nullable public String getSameSite()
Return the cookie "SameSite" attribute, ornull
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
equals
public boolean equals(@Nullable Object other)
- 覆盖:
equals
在类中HttpCookie
hashCode
public int hashCode()
- 覆盖:
hashCode
在类中HttpCookie
toString
public String toString()
- 覆盖:
toString
在类中HttpCookie
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 namevalue
- 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. Unlikefrom(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 namevalue
- the cookie value- 返回:
- a builder to create the cookie with
- 从以下版本开始:
- 5.2.5