
<%...@page contentType="text/html; charset=GBK" isELIgnored="false"%>
<%...
if (application.getAttribute("count") == null) {
application.setAttribute("count", new Integer(0));
}
Integer count = (Integer) application.getAttribute("count");
application.setAttribute("count", new Integer(count.intValue() + 1));
%>
<html>
<head>
<title>页面被访问数统计</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
</head>
<body bgcolor="#ffffff">
<form action="RequestJsp.jsp">
<p></p>
<p></p>
<h1>
<input type="submit" name="sub" value="点击!"/>
</h1>
<!--输出访问次数 -->
<h1> 此页面已被访问了${applicationScope.count}次
</h1>
</form>
</body>
</html>
本文介绍了一个简单的网页访问计数统计实现方法。通过在服务器端使用application对象来记录页面的总访问次数,并在每次访问时更新该计数。此外,还展示了如何在JSP页面中显示当前的访问次数。
4539

被折叠的 条评论
为什么被折叠?



