jsp实现session计数
一、在jsp中写java代码
<% Integer count_today = (Integer)session.getAttribute("COUNT"); if ( count_today == null ) { count_today = new Integer(1); session.setAttribute("COUNT", count_today); } else { count_today = new Integer(count_today.intValue() + 1); session.setAttribute("COUNT", count_today); } // out.println("<div><b>日访问量: " + count_today + " 次</b></div>"); %>
二、页面赋值
日访问量:<span><%=count_today%></span>
三、实现效果