类 CookieUtils
java.lang.Object
cn.herodotus.stirrup.web.core.definition.utils.HttpUtils
cn.herodotus.stirrup.web.core.servlet.utils.CookieUtils
Description: Cookie 操作工具类
- 作者:
- : gengwei.zheng
- Date:
- : 2023/9/2 16:38
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String获取 Cookie 属性值static StringgetAnyFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值static StringgetAnyFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值static StringgetAnyFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值static jakarta.servlet.http.Cookie获取 Cookie 对象static StringgetFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name) 获取 Cookie 请求头中,某个属性的值static StringgetFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String name) 获取 Cookie 请求头中,某个属性的值static StringgetFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String name) 获取 Cookie 请求头中,某个属性的值static void清除 某个指定的cookiestatic voidset(jakarta.servlet.http.HttpServletResponse response, String name, String value, int maxAgeInSeconds) 设置cookie从类继承的方法 cn.herodotus.stirrup.web.core.definition.utils.HttpUtils
get, get, getAny, isGetRequest, isPostRequest
-
构造器详细资料
-
CookieUtils
public CookieUtils()
-
-
方法详细资料
-
getCookie
public static jakarta.servlet.http.Cookie getCookie(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name) 获取 Cookie 对象- 参数:
httpServletRequest-HttpServletRequestname- Cookie中的属性名- 返回:
Cookie对象
-
get
获取 Cookie 属性值- 参数:
httpServletRequest-HttpServletRequestname- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getFromCookieHeader
public static String getFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name) 获取 Cookie 请求头中,某个属性的值- 参数:
httpServletRequest-HttpServletRequestname- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getFromCookieHeader
public static String getFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String name) 获取 Cookie 请求头中,某个属性的值- 参数:
serverHttpRequest-ServerHttpRequestname- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getFromCookieHeader
public static String getFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String name) 获取 Cookie 请求头中,某个属性的值- 参数:
httpInputMessage-HttpInputMessagename- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getAnyFromCookieHeader
public static String getAnyFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值- 参数:
httpServletRequest-HttpServletRequestname- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getAnyFromCookieHeader
public static String getAnyFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值- 参数:
serverHttpRequest-ServerHttpRequestname- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
getAnyFromCookieHeader
public static String getAnyFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String... name) 从 Cookie 请求头中,找到给定任意给定属性的值- 参数:
httpInputMessage-HttpInputMessagename- Cookie中的属性名- 返回:
- 如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
-
remove
清除 某个指定的cookie- 参数:
response- HttpServletResponsekey- cookie key
-
set
public static void set(jakarta.servlet.http.HttpServletResponse response, String name, String value, int maxAgeInSeconds) 设置cookie- 参数:
response- HttpServletResponsename- cookie namevalue- cookie valuemaxAgeInSeconds- maxage
-