日期:2014-05-17  浏览次数:20803 次

(求助)关于j2ee中application的setAttribute不能创建值
	
                public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletExceptionIOException {

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