会话 (sessions)

sessions 端点提供了由 Spring Session 管理的应用程序 HTTP 会话信息。

检索会话

要检索会话,请向 /actuator/sessions 发送 GET 请求,如以下基于 curl 的示例所示

$ curl 'https://:8080/actuator/sessions?username=alice' -i -X GET

前面的示例检索了用户名为 alice 的所有会话。结果响应类似于以下内容

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 789

{
  "sessions" : [ {
    "attributeNames" : [ ],
    "creationTime" : "2025-11-20T14:33:59.914866807Z",
    "expired" : false,
    "id" : "40b429f0-57dd-4aeb-a5ad-241bea75fcb7",
    "lastAccessedTime" : "2025-11-20T16:33:47.914867419Z",
    "maxInactiveInterval" : 1800
  }, {
    "attributeNames" : [ ],
    "creationTime" : "2025-11-20T04:33:59.914198661Z",
    "expired" : false,
    "id" : "13bd41f7-d039-4969-87bf-298833e7d86d",
    "lastAccessedTime" : "2025-11-20T16:33:14.914204682Z",
    "maxInactiveInterval" : 1800
  }, {
    "attributeNames" : [ ],
    "creationTime" : "2025-11-20T11:33:59.914862470Z",
    "expired" : false,
    "id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
    "lastAccessedTime" : "2025-11-20T16:33:22.914864303Z",
    "maxInactiveInterval" : 1800
  } ]
}

查询参数

该端点使用查询参数来限制其返回的会话。下表显示了唯一必需的查询参数

参数 描述

username

用户的名称。

响应结构

响应包含匹配会话的详细信息。下表描述了响应的结构

路径 类型 描述

sessions

数组

给定用户名的会话。

sessions.[].id

字符串

会话 ID。

sessions.[].attributeNames

数组

存储在会话中的属性名称。

sessions.[].creationTime

字符串

会话创建的时间戳。

sessions.[].lastAccessedTime

字符串

会话上次访问的时间戳。

sessions.[].maxInactiveInterval

数字

会话过期前的最大允许非活动时间,单位为秒。

sessions.[].expired

布尔值

会话是否已过期。

检索单个会话

要检索单个会话,请向 /actuator/sessions/{id} 发送 GET 请求,如以下基于 curl 的示例所示

$ curl 'https://:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X GET

前面的示例检索了 ID 为 4db5efcc-99cb-4d05-a52c-b49acfbb7ea9 的会话。结果响应类似于以下内容

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 208

{"attributeNames":[],"creationTime":"2025-11-20T11:33:59.914862470Z","expired":false,"id":"4db5efcc-99cb-4d05-a52c-b49acfbb7ea9","lastAccessedTime":"2025-11-20T16:33:22.914864303Z","maxInactiveInterval":1800}

响应结构

响应包含请求会话的详细信息。下表描述了响应的结构

路径 类型 描述

id

字符串

会话 ID。

attributeNames

数组

存储在会话中的属性名称。

creationTime

字符串

会话创建的时间戳。

lastAccessedTime

字符串

会话上次访问的时间戳。

maxInactiveInterval

数字

会话过期前的最大允许非活动时间,单位为秒。

expired

布尔值

会话是否已过期。

删除会话

要删除会话,请向 /actuator/sessions/{id} 发送 DELETE 请求,如以下基于 curl 的示例所示

$ curl 'https://:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X DELETE

前面的示例删除了 ID 为 4db5efcc-99cb-4d05-a52c-b49acfbb7ea9 的会话。

© . This site is unofficial and not affiliated with VMware.