曦~妍  

 

 

 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>Insert title here</title>
 8 </head>
 9 <body>
10 <%
11 
12 String str=application.getInitParameter("test2");
13 out.print("test2="+str+"<br>");
14 //模拟计数器
15 //初始化
16 //取出计数器的当前值
17 Object obj=application.getAttribute("count");
18 if(obj==null)
19 {
20     
21 application.setAttribute("count", 1);
22 obj=1;
23 }
24 
25 //模拟计数器++(+1)的运行方式
26 //数据转型,同object转成数值型
27 long count=Long.parseLong(obj.toString());
28 count++;
29 //out.print("count="+obj.toString());
30 out.print("count="+count);
31 //取完之后将新的值在放到里面继续叠加运算
32 application.setAttribute("count", count);
33 %>
34 </body>
35 </html>

 

posted on 2016-06-29 15:12  曦~妍  阅读(377)  评论(0编辑  收藏  举报