会话 (sessions)
sessions 端点提供有关由 Spring Session 管理的应用程序 HTTP 会话的信息。
获取会话
要获取会话,可以按照以下基于 curl 的示例发送 GET 请求到 /actuator/sessions:
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" : [ {
"id" : "1dbec08b-b391-4325-8f5b-22c73ac656f2",
"attributeNames" : [ ],
"creationTime" : "2024-08-22T04:50:32.636258962Z",
"lastAccessedTime" : "2024-08-22T16:49:47.636264522Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
"attributeNames" : [ ],
"creationTime" : "2024-08-22T11:50:32.636974764Z",
"lastAccessedTime" : "2024-08-22T16:49:55.636978341Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "31093d80-33f0-445a-ad6e-fafb363aad55",
"attributeNames" : [ ],
"creationTime" : "2024-08-22T14:50:32.636981266Z",
"lastAccessedTime" : "2024-08-22T16:50:20.636981997Z",
"maxInactiveInterval" : 1800,
"expired" : false
} ]
}
响应结构
响应包含匹配会话的详细信息。下表描述了响应的结构:
路径 |
类型 |
描述 |
|
|
给定用户名的会话。 |
|
|
会话的 ID。 |
|
|
存储在会话中的属性名称。 |
|
|
会话创建的时间戳。 |
|
|
会话最后一次访问的时间戳。 |
|
|
会话在过期前允许的不活动的最长时间(以秒为单位)。 |
|
|
会话是否已过期。 |
获取单个会话
要获取单个会话,可以按照以下基于 curl 的示例发送 GET 请求到 /actuator/sessions/{id}:
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":"2024-08-22T11:50:32.636974764Z","lastAccessedTime":"2024-08-22T16:49:55.636978341Z","maxInactiveInterval":1800,"expired":false}