HQL

  SELECT id,paidamount,paymentDeadline FROM exchange.c_agreement_amount;如何将上面的查询语句,在action里面用 对象写出来。

解决方案 »

  1.   

    class CagreementAmount
    {
    private String id;
    private String paidamount;
    private String paymentDeadline;
    }
      

  2.   

    SELECT id,paidamount,paymentDeadline FROM exchange.c_agreement_amount;在mysql里面的查询结果 如何在action里面写HQL语句,将在mysql里面的查询结果,在jsp页面上显示出来。
      

  3.   

    假定exchange.c_agreement_amount是一个表
    那就像2楼一样建一个类class CagreementAmount
    {
    private String id;
    private String paidamount;
    private String paymentDeadline;//gatter/setter
    }接着在action里试一下这样
    select c.id,c.paidamount,c.paymentDeadline from CagreementAmount as c
      

  4.   

    在DAO层查出结果、在action中接收下、然后在action中放到request里、然后在jsp中循环显示就行了啊、挺简单的问题、学校里没学过吗?
      

  5.   

    不知道LZ用没用struts2   ActionContext.getContext.put("find","这里存放从数据库查询的值 例如数据存放在list里面"); 
    页面显示数据
    JSTL
    <c:forEach items="${find}" var="f">
       ${f.id}
       ${f.paidamount}
       ${f.paymentDeadline }
    </c:forEach>等多很多种方法
      

  6.   

    假设实体类Exchangerequest.setAttribute("find","这里存放从数据库查询的值 例如数据存放在list集合中)页面显示数据 
    <%
    List list = (List)request.getAttribute("find");
    for(int i=0;i<list.size();i++){
        Exchange exchange = (Exchange)list.get(i);
        out.print(exchange.id);
        out.print(exchange.paidamount);
        out.print(exchange.paymentDeadline);
    }
    %>
      

  7.   

    看用什么链接的数据库勒,直接写成String 型的,让后把他拿去执行查询操作
      

  8.   

    这是在dao层写的语句
    public List getamountListByCAgreementAmount(CAgreementAmount agreementAmount){
     String sql = "SELECT id,paidamount,paymentDeadline FROM CAgreementAmount";
    List result = this.getHibernateTemplate().find(sql, agreementAmount);
    if (result.size() == 0) {
    return null;
    }
           return result;
       }
    不知道对不对 在action里面如何去写,在jsp里面如何去写。
    主营收入对应着 paidamount  时间 是paymentDeadline 在jsp页面上显示的是一月到十二月 让后还有一个12个月的和
      

  9.   

    在 mysql中 查询语句 SELECT id,paidamount,paymentDeadline FROM CAgreementAmount;
    在jsp页面上 行显示一月,二月 到十二月 还有一个十二月总和   
       列显示的是主营收入 只要把paidamount的数值分别在行里显示出来。