
<%...@pagecontentType="text/html;charset=GBK"isELIgnored="false"%>
<%...
if(application.getAttribute("count")==null){
application.setAttribute("count",newInteger(0));
}
Integercount=(Integer)application.getAttribute("count");
application.setAttribute("count",newInteger(count.intValue()+1));
%>
<html>
<head>
<title>页面被访问数统计</title>
<metahttp-equiv="Content-Type"content="text/html;charset=GBK"/>
</head>
<bodybgcolor="#ffffff">
<formaction="RequestJsp.jsp">
<p></p>
<p></p>
<h1>
<inputtype="submit"name="sub"value="点击!"/>
</h1>
<!--输出访问次数-->
<h1>此页面已被访问了${applicationScope.count}次
</h1>
</form>
</body>
</html>
本文介绍了一个简单的页面访问计数器的实现方法,通过在服务器端使用 JSP 技术记录并显示页面被访问的次数。该计数器利用应用范围变量存储累计的访问次数,并在每次页面加载时更新这一数值。
4538

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



