<%@ 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>Insert title here</title>
</head>
<h1>统计页面访问量</h1>
<HR>
<body>
<%
int number=0;
if(application.getAttribute("number")==null)
number=1;
else{
//获取application范围内的变量,并转换为int型
number=Integer.parseInt(application.getAttribute("number").toString());
number++;
}
out.println("访问量:"+application.getAttribute("number"));
//将自增后的number值保存。
application.setAttribute("number",number);
%>
</body>
</html>
统计页面访问量(JSP)
最新推荐文章于 2024-08-12 07:54:21 发布