zoukankan      html  css  js  c++  java
  • include和application

    include指令

    语法:<%@ include  file=”路径+文件名” %>

    把指定的文件包含到当前jsp中。

    application(应用的全局变量)

    实现用户之间的数据共享

    常用方法:

    Application.setAttribute(Stirng key,Object value);

    Application.getAttribute(String key);

     1 <%@page import="java.text.SimpleDateFormat"%>
     2 <%@page import="java.util.Date"%>
     3 <%@ page language="java" contentType="text/html; charset=utf-8"
     4     pageEncoding="utf-8"%>
     5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     6 <html>
     7 <head>
     8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     9 <title>访问人数</title>
    10 </head>
    11 <body>
    12     <%
    13         Integer count=(Integer) application.getAttribute("count");
    14         if(count != null){
    15             count = count+1;
    16         }else{
    17             count = 1; 
    18         }
    19         application.setAttribute("count", count);
    20     %>
    21     
    22     <%
    23         Integer i=(Integer)application.getAttribute("count") ;
    24         out.print("统计访问量:目前有"+i+"个人访问本网站");
    25     %>
    26     
    27 </body>
    28 </html>
    示例
  • 相关阅读:
    用JAVA自己画一张二维码
    20.custom自定义线程池
    19.线程池的使用
    7.volatile关键字
    8.volatile原子性
    10.线程通信CountDownLatch
    9.线程通信wait、notify
    11.线程通信CountDownLatch
    14.ThreadLocal
    13.FutureTask异步计算
  • 原文地址:https://www.cnblogs.com/yang82/p/7281725.html
Copyright © 2011-2022 走看看