[jsp]代码库
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jsp网页计数器(防刷新)</title>
<style type="text/css">
h2 {
text-align: center;
color: #EF9581;
font-family: "微软雅黑", Verdana, sans-serif, "宋体";
font-weight: bold;
font-size: 36px;
}
</style>
</head>
<body>
<br>
<%
if (application.getAttribute("count") == null) {
application.setAttribute("count", 0);
}
long count = Long.parseLong(application.getAttribute("count")
.toString());
if (session.getAttribute("Visited") == null) {
session.setAttribute("Visited", "Y");
session.setMaxInactiveInterval(60 * 60 * 24);
count += 1;
application.setAttribute("count", count);
}
%>
<h2>
您是第<%=count%>位访问者
</h2>
</body>
</html>
[代码运行效果截图]
高级设计师
by: 由月君 发表于:2012-10-09 00:11:11 顶(1) | 踩(0) 回复
唔,不错,还可以
回复评论