會話 (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
} ]
}
響應結構
響應包含匹配會話的詳細資訊。下表描述了響應的結構
| 路徑 | 型別 | 描述 |
|---|---|---|
|
|
給定使用者名稱的會話。 |
|
|
會話 ID。 |
|
|
儲存在會話中的屬性名稱。 |
|
|
會話建立的時間戳。 |
|
|
會話上次訪問的時間戳。 |
|
|
會話過期前的最大允許非活動時間,單位為秒。 |
|
|
會話是否已過期。 |
檢索單個會話
要檢索單個會話,請向 /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}