HttpSessionListener是做什么用的?
publicclassActiveUserListenerimplementsHttpSessionListener{privatestaticintsessionCou...
public class ActiveUserListener implements HttpSessionListener {
private static int sessionCount = 0;
private static Map sessionMaps = new HashMap(); //存放session的集合类
public void sessionCreated(HttpSessionEvent arg0) {
HttpSession session = arg0.getSession();
session.setMaxInactiveInterval(1000);
String sessionId = session.getId();
sessionMaps.put(sessionId, session);
sessionCount++;
}
public void sessionDestroyed(HttpSessionEvent arg0) {
sessionCount--;
String sessionId = arg0.getSession().getId();
sessionMaps.remove(sessionId);//利用会话ID标示特定会话
}
public static int getSessionCount() {
return sessionCount;
}
public static Map getSessionMaps() {
return sessionMaps;
}
}
这段代码是什么意思 展开
private static int sessionCount = 0;
private static Map sessionMaps = new HashMap(); //存放session的集合类
public void sessionCreated(HttpSessionEvent arg0) {
HttpSession session = arg0.getSession();
session.setMaxInactiveInterval(1000);
String sessionId = session.getId();
sessionMaps.put(sessionId, session);
sessionCount++;
}
public void sessionDestroyed(HttpSessionEvent arg0) {
sessionCount--;
String sessionId = arg0.getSession().getId();
sessionMaps.remove(sessionId);//利用会话ID标示特定会话
}
public static int getSessionCount() {
return sessionCount;
}
public static Map getSessionMaps() {
return sessionMaps;
}
}
这段代码是什么意思 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询