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>
    示例
  • 相关阅读:
    vim cheat
    latex base
    latex font
    lstings
    使用React 如何设计 模板自定义的框架
    react hooks 的更进一步适应性使用
    IDEA反编译jar包源码
    Redis Lua实战
    Spring AOP拦截并打印controller层请求日志
    漏桶算法和令牌桶算法的区别
  • 原文地址:https://www.cnblogs.com/yang82/p/7281725.html
Copyright © 2011-2022 走看看