gpt4 book ai didi

java - 如何根据事件更新多个 session

转载 作者:行者123 更新时间:2023-12-02 07:18:16 26 4
gpt4 key购买 nike

在我们的 Web 应用程序中(在使用 Struts 的 JBoss 中),我们使用 session 主要是为了安全以及为用户缓存一些数据。因此,每个登录到应用程序的用户都有一个 session 和缓存在其中的不同数据。

基于某些参数更改,我想更改已登录用户子集(即具有 session )的缓存

这能实现吗?到目前为止,我还没有从一般搜索中找到任何东西。

最佳答案

您可以使用HttpAttributeListener

一个基本示例 here

HttpSessionAttributeListener:

The HttpSessionAttributeListener interface enables an object to monitor changes to the attribute lists of sessions within a given Web application. The HttpSessionAttributeListener in turn extends java.util.EventListener. The methods in it are

  • attributeAdded(HttpSessionBindingEvent se)- This is the notification that an attribute has been added to a session.
  • attributeRemoved(HttpSessionBindingEvent se)- This is the notification that an attribute has been removed from a session.
  • attributeReplaced(HttpSessionBindingEvent se)- This is the notification that an attribute has been replaced in a session.

关于java - 如何根据事件更新多个 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14628513/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com