【发布时间】:2018-03-18 00:03:15
【问题描述】:
我想使用 Google Guice 的 SessionScope,在会话被销毁之前,我想从 SessionScoped 对象中获取数据。
我尝试使用HttpSessionListener.sessionDestroyed(),但此时我没有会话属性。
是否有其他方法可以检查会话属性何时被破坏?
【问题讨论】:
标签: servlets jakarta-ee guice httpsession
我想使用 Google Guice 的 SessionScope,在会话被销毁之前,我想从 SessionScoped 对象中获取数据。
我尝试使用HttpSessionListener.sessionDestroyed(),但此时我没有会话属性。
是否有其他方法可以检查会话属性何时被破坏?
【问题讨论】:
标签: servlets jakarta-ee guice httpsession
HttpSessionListener.sessionDestroyed(HttpSessionEvent se) 参数使您可以使用HttpSessionEvent.getSession() 访问 HttpSession。
然后您可以以通常的方式访问会话属性。
请注意,调用它时通常没有关联的 HttpRequest。
【讨论】: