网页访问统计帮助类

xiaoxiao2021-02-28  24

//获取网页流量的统计 ServletContext context = getServletContext(); Integer count = null; synchronized(context) { count = (Integer) context.getAttribute("counter"); if (null == count) { count = new Integer(1); } else { count = new Integer(count.intValue() + 1); } context.setAttribute("counter", count); } System.out.println("网页流量:"+count); //tomcat重启以后,会被清空。
转载请注明原文地址: https://www.6miu.com/read-2628769.html

最新回复(0)