可以先定义一个对象,然后把值赋给他。在把他放到request或者session里面。这样就可以在jsp的到这个值了。

解决方案 »

  1.   

    我的问题关键是如何给对象赋值。取出的值是double型的,不是String型的。所以不能将double型的值赋值给对象。 高手有什么好的解决方法。
      

  2.   

    从数据库中取得的求和值为double型。要赋值的对象为Double型  如何将double型的值赋值给Double型的对象。
     最好把赋值代码写一下。谢谢!
      

  3.   

    将double型的做类型转换然后赋给对象呢?
      

  4.   

    double a = 0.000;
    Double b = new Double( a)
    你试试这个。不知能能行。
      

  5.   

    或者可以写成这样
    Double a=0;
    a=rs.getDouble(sum);//sum 是从数据库求得和。
      

  6.   

    private Double  lrealQuantity ;
    private Double countNum; 
    public Double getCountNum() {
    return countNum;
    }
    public void setCountNum(Double countNum) {
    this.countNum = countNum;
    }

    public Double getLrealQuantity() {
    return lrealQuantity;
    }
    public void setLrealQuantity(Double lrealQuantity) {
    this.lrealQuantity = lrealQuantity;
    }
    public StoreUnitAction()
    {
    object =new StoreUnit(); 
    }
    public String inCountList() 
    {    


     String hql_OC = " from StoreUnit s";
     List keepList = objectDao.find(hql_OC);
     for(int i=0;i<keepList.size();i++)
     {  
    double countStoreNum=0.00 ;
             countStoreNum+=((StoreUnit)keepList.get(i)).getLrealQuantity().doubleValue();
     }

          //  此处填写 将countStoreNum的值赋值给countNum这个变量:      //  (使用下面方法报错,说countStoreNum cannot be resolved)
          //   如:countNum= new Double(countStoreNum);  
     return SUCCESS;  
             
    }
    这是程序代码:对于上述报错问题应怎样解决.
      

  7.   

     for(int i=0;i<keepList.size();i++)
     {  
    double countStoreNum=0.00 ;
             countStoreNum+=((StoreUnit)keepList.get(i)).getLrealQuantity().doubleValue();
     }

          //  此处填写 将countStoreNum的值赋值给countNum这个变量:      //  (使用下面方法报错,说countStoreNum cannot be resolved)
          //   如:countNum= new Double(countStoreNum);
    你在for里边定义的变量,在外边肯定找不到了.是不是需要改为: double countStoreNum=0.00 ;
     for(int i=0;i<keepList.size();i++)
     {  
             countStoreNum+=((StoreUnit)keepList.get(i)).getLrealQuantity().doubleValue();
     }