论坛统计在线人数
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));
}声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
