zoukankan      html  css  js  c++  java
  • application的使用(实现计数器)

    application在整个WEB项目中共享使用数据。

    常用方法:
     getAttribute();
     setAttribute();
    示列:

     <%
        Object count=application.getAttribute("count");
        if(count==null){
         //application中未存放count
         application.setAttribute("count", new Integer(1));
        }else{
         //application中已经存放count
         Integer i=(Integer)count;
         application.setAttribute("count", i.intValue()+1);
        }
        Integer icount=(Integer)application.getAttribute("count");
        out.println("页面被访问了"+icount.intValue()+"次");
        %>

    可以直接将此段代码放在需要显示的JSP页面中。

  • 相关阅读:
    任务安排(代价提前付)
    10 01模拟赛订正
    哈希hash
    初学期望
    P1251 递推专练3
    P1229-神秘岛
    P1228-重叠的图像
    白银莲花池
    求强连通分量
    割边
  • 原文地址:https://www.cnblogs.com/fifiyong/p/5949568.html
Copyright © 2011-2022 走看看