首页 > 其他 > 详细

Cookie(页面访问次数)

时间:2017-12-27 13:52:04      阅读:210      评论:0      收藏:0      [点我收藏+]
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"  
  2.     pageEncoding="UTF-8"%>  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  4. <html>  
  5. <head>  
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  7. <title>页面访问计数器</title>  
  8. </head>  
  9. <body>  
  10. <%  
  11.    Object obj=application.getAttribute("counter");  
  12.    if(obj==null){  
  13.        application.setAttribute("counter",new Integer(1));  
  14.        out.println("该页面被访问1次!<br />");  
  15.    }else{  
  16.        int counterValue=Integer.parseInt(obj.toString());  
  17.        counterValue++;  
  18.        out.println("该页面被访问"+counterValue+"次!<br />");  
  19.        application.setAttribute("counter", counterValue);  
  20.    }  
  21. %>  
  22.   
  23. </body>  
  24. </html> 

Cookie(页面访问次数)

原文:https://www.cnblogs.com/scup1122/p/8124759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!