refresh.jsp
<%
Integer count=(Integer)application.getAttribute("count");
<--!将count强转为Integer类型 -->
if(count==null){<--!判断count是否为空 -->
application.setAttribute("count",1);
}else{
application.setAttribute("count",count+1);}
%><--!如果count不为空 count+1 -->
<p>第<%=application.getAttribute("count")%>次访问</p>
本文展示了一个使用JSP实现的简单应用示例,通过在应用级别设置计数器来记录页面被访问的次数,并在每次访问时更新该计数器。
1257

被折叠的 条评论
为什么被折叠?



