如何查找会话中是添加还是删除了所有数据



我使用以下getSession()方法来获取存储在会话中的所有属性。有没有办法找出用户每次浏览应用程序中的不同页面时是否添加或删除了所有数据。

  protected HttpServletRequest getRequest() {
        return (HttpServletRequest) FacesContext.getCurrentInstance()
                .getExternalContext().getRequest();
    }
  protected HttpSession getSession() {
        return getRequest().getSession();
    }

HttpSessionAttributeListener 接口就是为此完成的。在 Web 应用中创建一个实现此接口并重写其方法的类。然后,使用 WebListener 注释或直接在 web.xml 文件中注册类。

最新更新