作用域范围

作用域

getAttribute(),setAttribute()

  • page 页面级,基本不用
  • request 一次请求
  • session 一次会话
  • application 整个web应用

示例

网站访问计数

    <%
      Integer count = (Integer) application.getAttribute("count");
      if(count == null){
          count = 1;
          application.setAttribute("count",count);
      }else{
          count++;
          application.setAttribute("count",count);
      }
    %>
posted @ 2020-03-07 21:35  末日浪漫  阅读(132)  评论(0)    收藏  举报