我有一个Session扩展的监听器PortalSessionListener。我有sessionCreated(HttpSessionEvent httpSessionEvent)和sessionDestroyed(HttpSessionEvent httpSessionEvent)方法
当我Session失效时(根据我在 web.xml 中的配置,15 分钟后),我的监听器被调用并Session失效。
在我的听众中,我想Cookie在注销用户之前清除值。所以,我想要Request和Response对象,以便我可以清除 Cookie 值并将其设置为Response.
但是,我怎样才能Request / Response在我的监听器中获取对象HttpSessionEvent?
我试过下面的代码。但是,当我的sessionDestroyed方法被调用或任何其他阶段时,这不会被调用。
public void requestInitialized(ServletRequestEvent servletRequestEvent)
{
log.debug("Entered into requestInitialized method");
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
log.debug("Request object created is :" +request);
}
有人建议实施Filter适合此要求(用于获取Request对象)。如何将其应用于我的场景?