在jsp中的聲明:
jsp中的聲明有兩種方法:一種是<% intcount=0%>,另一種是<%! intcount=0%>,現(xiàn)在講講第二種.
1、測試條件:
假設(shè)有兩個頁面test1.jsp和test2.jsp都有如下代碼:
<%! intcount=0%>
<%intcount+=1;
out.print("第"+intcount+"人次進(jìn)入本頁面!");
%>
2、測試環(huán)境:jrun3+jdk1.2
3、測試結(jié)果:
·這個intcount只要是在同一個頁面,就相當(dāng)于一個asp中的一個application,各個用戶共享這個變量,且初始化 intcount=0只在第一個用戶登陸時執(zhí)行.
·但不同的頁面互不影響.
新聞熱點(diǎn)
疑難解答
圖片精選