此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Boot 3.3.4! |
此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Boot 3.3.4! |
端点提供有关由 Spring Session 管理的应用程序的 HTTP 会话的信息。sessions
检索会话
要检索会话,请向 发出请求,如以下基于 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" : "205bdeeb-9c3d-4e98-8f72-fa1447055f92",
"attributeNames" : [ ],
"creationTime" : "2024-10-02T10:55:08.184109410Z",
"lastAccessedTime" : "2024-10-02T12:54:56.184110141Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "52c20715-8631-4641-bac6-5105f5526792",
"attributeNames" : [ ],
"creationTime" : "2024-10-02T00:55:08.183221122Z",
"lastAccessedTime" : "2024-10-02T12:54:23.183229207Z",
"maxInactiveInterval" : 1800,
"expired" : false
}, {
"id" : "4db5efcc-99cb-4d05-a52c-b49acfbb7ea9",
"attributeNames" : [ ],
"creationTime" : "2024-10-02T07:55:08.184103729Z",
"lastAccessedTime" : "2024-10-02T12:54:31.184106474Z",
"maxInactiveInterval" : 1800,
"expired" : false
} ]
}
响应结构
响应包含匹配会话的详细信息。 下表描述了响应的结构:
路径 | 类型 | 描述 |
---|---|---|
|
|
给定用户名的会话。 |
|
|
会话的 ID。 |
|
|
会话中存储的属性的名称。 |
|
|
创建会话时的时间戳。 |
|
|
上次访问会话时的时间戳。 |
|
|
会话过期前允许的最长非活动时间(以秒为单位)。 |
|
|
会话是否已过期。 |
参数 | 描述 |
---|---|
|
用户的名称。 |
路径 | 类型 | 描述 |
---|---|---|
|
|
给定用户名的会话。 |
|
|
会话的 ID。 |
|
|
会话中存储的属性的名称。 |
|
|
创建会话时的时间戳。 |
|
|
上次访问会话时的时间戳。 |
|
|
会话过期前允许的最长非活动时间(以秒为单位)。 |
|
|
会话是否已过期。 |
检索单个会话
要检索单个会话,请向 发出请求,如以下基于 curl 的示例所示:GET
/actuator/sessions/{id}
$ curl 'http://localhost:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X GET
前面的示例使用 of 检索会话。
生成的响应类似于以下内容: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-10-02T07:55:08.184103729Z","lastAccessedTime":"2024-10-02T12:54:31.184106474Z","maxInactiveInterval":1800,"expired":false}
路径 | 类型 | 描述 |
---|---|---|
|
|
会话的 ID。 |
|
|
会话中存储的属性的名称。 |
|
|
创建会话时的时间戳。 |
|
|
上次访问会话时的时间戳。 |
|
|
会话过期前允许的最长非活动时间(以秒为单位)。 |
|
|
会话是否已过期。 |
删除会话
要删除会话,请向 发出请求,如以下基于 curl 的示例所示:DELETE
/actuator/sessions/{id}
$ curl 'http://localhost:8080/actuator/sessions/4db5efcc-99cb-4d05-a52c-b49acfbb7ea9' -i -X DELETE
前面的示例删除了具有 of 的会话。id
4db5efcc-99cb-4d05-a52c-b49acfbb7ea9