您的位置:首页 > 移动开发

点击量统计_application

2015-11-10 15:51 393 查看
<html>
<head>
<title>Applcation object in JSP</title>
</head>
<body>
<%
Integer Count =
(Integer)application.getAttribute("Counter");<span style="color:#3333ff;">//Count默认值为 0</span>
if( Count ==null || Count == 0 ){
/* 第一次访问 */
out.println("Welcome to my website!");
Count = 1;
}else{
/* 返回访问值 */
out.println("Welcome back to my website!");
Count += 1;
}
application.setAttribute("Counter", Count);<span style="color:#3333ff;">//设置参数Count ,不能直接设置为数字 1 等;</span>
%>
<center>
<p>Total number of visits: <%= hitsCount%></p>
</center>
</body>
</html>
</pre><pre name="code" class="html">

application语法结构:

application.setAttribute(String Key, Object Value);

application.getAttribute(String Key);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: