统计在线人数

1         ServletContext sc = this.getServletContext();
2         Long personCount = (Long)sc.getAttribute("personCount");
3         if(personCount==null){
4             personCount=(long)0;
5             sc.setAttribute("personCount", personCount);
6             
7         }
8         sc.setAttribute("personCount", (personCount+1));
9         System.out.println("当前在线人数:"+sc.getAttribute("personCount"));    

 

posted @ 2017-09-02 09:39  狂妄的老头  阅读(169)  评论(0编辑  收藏  举报