会话 (sessions
)
sessions
端点提供有关由 Spring Session 管理的应用程序 HTTP 会话的信息。
获取会话
要获取会话,向 /actuator/sessions
发送 GET
请求,如下面的基于 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: 771
{
"sessions" : [ {
"id" : "be6ca414-c473-4234-bdaa-30ec05354cfc",
"attributeNames" : [ ],
"creationTime" : "2025-05-25T08:03:22.050264Z",
"lastAccessedTime" : "2025-05-25T10:03:10.050264Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "37de89a7-eb68-4b92-8d17-9c5f3a1230b5",
"attributeNames" : [ ],
"creationTime" : "2025-05-24T22:03:22.049451Z",
"lastAccessedTime" : "2025-05-25T10:02:37.049457Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
"attributeNames" : [ ],
"creationTime" : "2025-05-25T05:03:22.050261Z",
"lastAccessedTime" : "2025-05-25T10:02:45.050263Z",
"maxInactiveInterval" : 1800,
"expired" : false
} ]
}
响应结构
响应包含匹配会话的详细信息。 下表描述了响应的结构:
Path | Type | Description |
---|---|---|
|
|
Sessions for the given username. |
|
|
ID of the session. |
|
|
Names of the attributes stored in the session. |
|
|
Timestamp of when the session was created. |
|
|
Timestamp of when the session was last accessed. |
|
|
Maximum permitted period of inactivity, in seconds, before the session will expire. |
|
|
Whether the session has expired. |
获取单个会话
要获取单个会话,向 /actuator/sessions/{id}
发送 GET
请求,如下面的基于 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: 202
{"id":"4db5efcc-99cb-4d05-a52c-b49acfbb7ea9","attributeNames":[],"creationTime":"2025-05-25T05:03:22.050261Z","lastAccessedTime":"2025-05-25T10:02:45.050263Z","maxInactiveInterval":1800,"expired":false}
响应结构
响应包含请求会话的详细信息。 下表描述了响应的结构:
Path | Type | Description |
---|---|---|
|
|
ID of the session. |
|
|
Names of the attributes stored in the session. |
|
|
Timestamp of when the session was created. |
|
|
Timestamp of when the session was last accessed. |
|
|
Maximum permitted period of inactivity, in seconds, before the session will expire. |
|
|
Whether the session has expired. |