java配置session监听器

首先创建一个session监听器类:

public class CustomeListener implements HttpSessionAttributeListener {

    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {
        // TODO Auto-generated method stub
        String sessionId = se.getSession().getId();

    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) {
        // TODO Auto-generated method stub
        String sessionId = se.getSession().getId();
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        // TODO Auto-generated method stub
        String sessionId = se.getSession().getId();
    }
}

然后配置web.xml文件:

  
<listener>  
  <listener-class>com.test.listener.CustomeListenerlistener-class>  
listener>

这样就完成了监听器的配置

你可能感兴趣的:(javaWeb)