用这种方法来记录访问量好像不对哟
每次用的时候都要使 count=0

解决方案 »

  1.   

    public void getCount(int count)
    {
      this.count=++count;
    }
    有问题,应该返回int吧:public int getCount()
    {
      return this.count;
    }
      

  2.   

    public void getCount(int count)
    {
      this.count=++count;
    }
    有问题,应该返回int吧:public int getCount()
    {
      return this.count;
    }
      

  3.   

    怎么可以把count这个属性变量用private来定义呢?
    再说getCount()方法也应该有返回值呀
      

  4.   

    我把我的bean改为:
    package mybeans;
    import java.io.*;
    public class Counter implements Serializable
    {
    public int count;
    public Counter()
    {
    count=0;
    }
    public void setCount(int count)
    {
    this.count=count;
    }
    public int getCount(int count)
    {
    this.count=++count;
                      return this.count;
    }
    }
    重新编译后,我的jsp页面还是和从前一样不能显示,错误信息也一样
      

  5.   

    你好像没有给getCount传参数阿!
    jsp中加两句:<jsp:setProperty name="sessionBean" property="count"/>    <jsp:setProperty name="applicationBean" property="count"/>方法getCount()改为:
    public int getCount()
    {
    this.count=++this.count;
                      return this.count;
    }
    感觉应该这样,没有试过,不一定对,仅作参考!
      

  6.   

    方法getCount()改为:
    public int getCount() {
        return (++count);
    }
    但是每次提交后得到的结果是一样的,因为你用的事class="mybeans.Count".
    用class的结果是,每次动态生成一个formbean的对象,没有达到计数的功能。