如果用遨游浏览器,为什么监听器只能监听第一次登录的用户,只有当第一次登录用户失效后,才能监听第二次的用户?
public class SessionListener implements HttpSessionListener,
HttpSessionAttributeListener {
org.apache.log4j.Logger logger;
public void sessionCreated(HttpSessionEvent arg0) {
}
public void sessionDestroyed(HttpSessionEvent arg0) {
}
@SuppressWarnings("unchecked")
public void attributeAdded(HttpSessionBindingEvent arg0) {
logger = LogInvoker.getSystemLogger(SessionListener.class);
if (arg0.getName().equals(SessionConstants.ONLINE_STAFF)) {
Map onlineSession = (Map) arg0.getSession().getServletContext().getAttribute(SessionConstants.ONLINE_SESSION);
OnLineStaff onlineStaff = (OnLineStaff) arg0.getValue();
if(onlineStaff!=null){
onlineSession = new HashMap();
}
onlineSession.put(onlineStaff.getBsbUser().getUserId() + "", arg0.getSession());
arg0.getSession().getServletContext().setAttribute(SessionConstants.ONLINE_SESSION, onlineSession);
logger.info(onlineStaff.getBsbUser().getUserName() + " logon!");
}
}
public void attributeRemoved(HttpSessionBindingEvent arg0) {
logger = LogInvoker.getSystemLogger(SessionListener.class);
if (arg0.getName().equals(SessionConstants.ONLINE_STAFF)) {
Map onlineSession = (Map) arg0.getSession().getServletContext()
.getAttribute(SessionConstants.ONLINE_SESSION);
OnLineStaff onlineStaff = (OnLineStaff) arg0.getValue();
if (onlineSession != null) {
onlineSession.remove(onlineStaff.getBsbUser().getUserId() + "");
}
logger.info(onlineStaff.getBsbUser().getUserName() + " logoff!");
}
}
public void attributeReplaced(HttpSessionBindingEvent arg0) {
}
}