你在页面中赋一个初值给Session。然后在页面中对session进行判断。如果她已经存在就不计数。

解决方案 »

  1.   

    先看一下该ip地址的session有没有访问,若无,则加一;有,怎不加。
    String userIp=(String)session.getValue("userip");
    if(userIp==null){
      计数器加一;
      String UserIp=request.getRemoteAddr();
      session.putValue("userip",UserIp);
      

  2.   

    String strCount = "" ;
    if(session.getAttribute("count")==null)
    {
    int count = 0 ;
    File f = new File((request.getRealPath("/"))+"\\count\\count.txt");
    BufferedReader br = new BufferedReader(new FileReader(f));
    strCount=br.readLine() ;
    count=Integer.parseInt(strCount)+1;
    strCount=(new Integer(count)).toString();
    PrintWriter pw = new PrintWriter(new FileWriter(f)) ;
    pw.println(strCount);
    pw.close();
    session.setAttribute("count",strCount);
    }
    else
    {
    strCount = session.getAttribute("count").toString();
    }
    把计数器改成这样就行了。///////如何防止用户更新页面刷新计数器!