牛骨文教育服务平台(让学习变的简单)
博文笔记

论坛统计在线人数

创建时间:2014-11-16 投稿人: 浏览次数:681

1  登录的action中 ,如果登录成功:

Integer c = (Integer) ActionContext.getContext().getApplication().get("userCount");
	if(c== null){
		ActionContext.getContext().getApplication().put("userCount", 1);
	}else{
	<span style="white-space:pre">	</span>ActionContext.getContext().getApplication().put("userCount", c+1);

	}
2.登录后的界面添加:

	<%
	Integer userCount= (Integer)application.getAttribute("userCount");%>
	<div>在线人数:<%=userCount %></div>
3.用户推出登录时:

AppAccount  acc = (AppAccount) getRequest().getSession().getAttribute("curr_user");
		if(acc!=null){
			getRequest().getSession().removeAttribute("curr_user");
			Integer cou = (Integer) ActionContext.getContext().getApplication().get("userCount");
			 ActionContext.getContext().getApplication().put("userCount",new Integer(cou-1));
		}




声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。