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));
}