类 CookieUtils

java.lang.Object
cn.herodotus.stirrup.web.core.definition.utils.HttpUtils
cn.herodotus.stirrup.web.core.servlet.utils.CookieUtils

public class CookieUtils extends HttpUtils

Description: Cookie 操作工具类

作者:
: gengwei.zheng
Date:
: 2023/9/2 16:38
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static String
    get(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
    获取 Cookie 属性值
    static String
    getAnyFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String... name)
    从 Cookie 请求头中,找到给定任意给定属性的值
    static String
    getAnyFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String... name)
    从 Cookie 请求头中,找到给定任意给定属性的值
    static String
    getAnyFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String... name)
    从 Cookie 请求头中,找到给定任意给定属性的值
    static jakarta.servlet.http.Cookie
    getCookie(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
    获取 Cookie 对象
    static String
    getFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
    获取 Cookie 请求头中,某个属性的值
    static String
    getFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String name)
    获取 Cookie 请求头中,某个属性的值
    static String
    getFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String name)
    获取 Cookie 请求头中,某个属性的值
    static void
    remove(jakarta.servlet.http.HttpServletResponse response, String key)
    清除 某个指定的cookie
    static void
    set(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

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • CookieUtils

      public CookieUtils()
  • 方法详细资料

    • getCookie

      public static jakarta.servlet.http.Cookie getCookie(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
      获取 Cookie 对象
      参数:
      httpServletRequest - HttpServletRequest
      name - Cookie中的属性名
      返回:
      Cookie 对象
    • get

      public static String get(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
      获取 Cookie 属性值
      参数:
      httpServletRequest - HttpServletRequest
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getFromCookieHeader

      public static String getFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String name)
      获取 Cookie 请求头中,某个属性的值
      参数:
      httpServletRequest - HttpServletRequest
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getFromCookieHeader

      public static String getFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String name)
      获取 Cookie 请求头中,某个属性的值
      参数:
      serverHttpRequest - ServerHttpRequest
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getFromCookieHeader

      public static String getFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String name)
      获取 Cookie 请求头中,某个属性的值
      参数:
      httpInputMessage - HttpInputMessage
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getAnyFromCookieHeader

      public static String getAnyFromCookieHeader(jakarta.servlet.http.HttpServletRequest httpServletRequest, String... name)
      从 Cookie 请求头中,找到给定任意给定属性的值
      参数:
      httpServletRequest - HttpServletRequest
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getAnyFromCookieHeader

      public static String getAnyFromCookieHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest, String... name)
      从 Cookie 请求头中,找到给定任意给定属性的值
      参数:
      serverHttpRequest - ServerHttpRequest
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • getAnyFromCookieHeader

      public static String getAnyFromCookieHeader(org.springframework.http.HttpInputMessage httpInputMessage, String... name)
      从 Cookie 请求头中,找到给定任意给定属性的值
      参数:
      httpInputMessage - HttpInputMessage
      name - Cookie中的属性名
      返回:
      如果 Cookie 存在属性名就返回对应的值,如果不存在则返回null
    • remove

      public static void remove(jakarta.servlet.http.HttpServletResponse response, String key)
      清除 某个指定的cookie
      参数:
      response - HttpServletResponse
      key - cookie key
    • set

      public static void set(jakarta.servlet.http.HttpServletResponse response, String name, String value, int maxAgeInSeconds)
      设置cookie
      参数:
      response - HttpServletResponse
      name - cookie name
      value - cookie value
      maxAgeInSeconds - maxage