会话(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" : "d0f4ebfd-53f3-4ac2-b155-393bec4223fe",
"attributeNames" : [ ],
"creationTime" : "2025-05-26T01:08:26.382283Z",
"lastAccessedTime" : "2025-05-26T03:08:14.382283Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "e7e4cede-4863-45d0-8572-3790843e8b49",
"attributeNames" : [ ],
"creationTime" : "2025-05-25T15:08:26.381431Z",
"lastAccessedTime" : "2025-05-26T03:07:41.381433Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
"attributeNames" : [ ],
"creationTime" : "2025-05-25T22:08:26.382281Z",
"lastAccessedTime" : "2025-05-26T03:07:49.382282Z",
"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-25T22:08:26.382281Z","lastAccessedTime":"2025-05-26T03:07:49.382282Z","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. |