public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
ServletContext application=this.getServletContext();
Integer accessCount=(Integer) application.getAttribute("accessCount");
if(accessCount==null)
accessCount=0;
else
accessCount=accessCount+1;
application.setAttribute("accessCouunt", accessCount);
out.println(accessCount);
}
经过我的调试,我发现accessCount的值永远都是null值,这到底是怎么回事啊?
为什么下面的application.setAttribute()不创建呢?
application j2ee
------解决方案--------------------
application.setAttribute("accessCouunt", accessCount);
//这里变量名不对,应该是accessCount