<%@page import="java.util.ArrayList"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% String str = "el"; request.setAttribute("s", str); request.setAttribute("st.str", "demo"); ArrayList al = new ArrayList(); al.add("test1"); al.add("test2"); request.setAttribute("al",al); Integer count = (Integer)application.getAttribute("count"); if(count == null) { application.setAttribute("count", 1); }else{ application.setAttribute("count", count + 1); } %> ${s }<br/> ${requestScope["st.str"] }<br/> ${al[1] }<br/> 浏览次数:${applicationScope.count } </body> </html>
代码如上,用application对象统计浏览次数时,并不是从一开始,第一次进去就显示2.请问哪里错了
快乐的时光
相关分类