Action中的方法
public String execute3() throws Exception{
String HQL = "from DeliverBill where customer.id="+id;
list = this.getDeliverBillService().findByHQL(HQL);
return SUCCESS;
}jsp页面<tr>
<td width="24%">客户名称:${ }</td>
<td width="24%">总额:${ }</td>
<td width="24%">付款:${ ]}</td> </tr>
<tr>
<td width="24%">
欠款:${ }
</td>
<td width="24%">
日期:${ }
</td>
<td width="24%">
是否审核:${ }
</td>
<td width="24%">
库管:${ }
</td>
</tr>
<tr style="height: 30px" class="">
<td width="24%">
出库负责人:${ }
</td>
<td width="24%">
收货人:${ }
</td>
<td width="24%">
开票人:${ }
</td>
<td width="84%" colspan="3">
备注:${ ]}
</td>
</tr>
public String execute3() throws Exception{
String HQL = "from DeliverBill where customer.id="+id;
list = this.getDeliverBillService().findByHQL(HQL);
return SUCCESS;
}jsp页面<tr>
<td width="24%">客户名称:${ }</td>
<td width="24%">总额:${ }</td>
<td width="24%">付款:${ ]}</td> </tr>
<tr>
<td width="24%">
欠款:${ }
</td>
<td width="24%">
日期:${ }
</td>
<td width="24%">
是否审核:${ }
</td>
<td width="24%">
库管:${ }
</td>
</tr>
<tr style="height: 30px" class="">
<td width="24%">
出库负责人:${ }
</td>
<td width="24%">
收货人:${ }
</td>
<td width="24%">
开票人:${ }
</td>
<td width="84%" colspan="3">
备注:${ ]}
</td>
</tr>
我看你hql查的是单条记录
你可以在action里直接传对象过去
private DeliverBill deliverBill;
if(list.size() != 0)
deliverBill = (DeliverBill)list.get(0);
再加个set()方法jsp页面:${deliverBill.属性}
return deliverBill;
} public void setDeliverBill(DeliverBill deliverBill) {
this.deliverBill = deliverBill;
}
public DeliverBill getDeliverBill() {
return deliverBill;
} public void setDeliverBill(DeliverBill deliverBill) {
this.deliverBill = deliverBill;
}
在struts2中主要还是set方法起作用,get方法加不加没多大关系
就在action这么写,
private DeliverBell deliverBell;public DeliverBill getDeliverBill() {
return deliverBill;
}
public void setDeliverBill(DeliverBill deliverBill) {
this.deliverBill = deliverBill;
}
修改execute3()方法
public String execute3() throws Exception{
String HQL = "from DeliverBill where customer.id="+id;
list = this.getDeliverBillService().findByHQL(HQL);
deliverBill=(DeliverBill)list.get(0);
return SUCCESS;
}
前台页面可以这么取
<td>${deliverBill.id}</td>
或者<td><s:property value="deliverBill.id"/></td>