| 此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Boot 3.5.5! | 
会话 (sessions)
这sessionsendpoint 提供有关由 Spring Session 管理的应用程序的 HTTP 会话的信息。
检索会话
要检索会话,请将GET请求/actuator/sessions,如以下基于 curl 的示例所示:
$ curl 'http://localhost: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-08-20T14:28:19.422298081Z",
    "expired" : false,
    "id" : "020fdbee-e1d4-4068-b392-8ec719d77d5e",
    "lastAccessedTime" : "2025-08-21T02:27:34.422305244Z",
    "maxInactiveInterval" : 1800
  }, {
    "attributeNames" : [ ],
    "creationTime" : "2025-08-21T00:28:19.423616248Z",
    "expired" : false,
    "id" : "88f67c9a-452f-491e-9387-a086f64c72a2",
    "lastAccessedTime" : "2025-08-21T02:28:07.423616719Z",
    "maxInactiveInterval" : 1800
  }, {
    "attributeNames" : [ ],
    "creationTime" : "2025-08-20T21:28:19.423611549Z",
    "expired" : false,
    "id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
    "lastAccessedTime" : "2025-08-21T02:27:42.423613533Z",
    "maxInactiveInterval" : 1800
  } ]
}响应结构
响应包含匹配会话的详细信息。 下表描述了响应的结构:
| 路径 | 类型 | 描述 | 
|---|---|---|
| 
 | 
 | 给定用户名的会话。 | 
| 
 | 
 | 会话的 ID。 | 
| 
 | 
 | 存储在会话中的属性的名称。 | 
| 
 | 
 | 创建会话时的时间戳。 | 
| 
 | 
 | 上次访问会话的时间戳。 | 
| 
 | 
 | 会话到期前允许的最长不活动时间(以秒为单位)。 | 
| 
 | 
 | 会话是否已过期。 | 
检索单个会话
要检索单个会话,请将GET请求/actuator/sessions/{id},如以下基于 curl 的示例所示:
$ curl 'http://localhost: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
{"id":"4db5efcc-99cb-4d05-a52c-b49acfbb7ea9","attributeNames":[],"creationTime":"2025-08-20T21:28:19.423611549Z","lastAccessedTime":"2025-08-21T02:27:42.423613533Z","maxInactiveInterval":1800,"expired":false}删除会话
要删除会话,请将DELETE请求/actuator/sessions/{id},如以下基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X DELETE前面的示例删除了带有id之4db5efcc-99cb-4d05-a52c-b49acfbb7ea9.