论坛首页 Java企业应用论坛

『提问』list该怎取?

浏览 4806 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2005-07-07  
String sql =  "select b.itemCode,a.poQty,b.itemName from Po_Line as a ,Item as b where a.itemId=b.itemId";
List po_Line_List = getHibernateTemplate().find(sql);


jsp:
<ww:iterator value="po_Line_List" status="index">
<ww:property/>
</ww:iterator>

为什么只能取得itemCode不能取得poQty,itemName?
   发表时间:2005-07-07  
mindyz 写道
String sql =  "select b.itemCode,a.poQty,b.itemName from Po_Line as a ,Item as b where a.itemId=b.itemId";
List po_Line_List = getHibernateTemplate().find(sql);


jsp:
<ww:iterator value="po_Line_List" status="index">
<ww:property/>
</ww:iterator>

为什么只能取得itemCode不能取得poQty,itemName?

你取的是po_Line_List[index],是一个集合/数组(没用过hibernate),还需要再iterator或者[index]一次。
0 请登录后投票
   发表时间:2005-07-07  
from两个类

本身就是把hibernate当成jdbc来用的错误示范

思维没oo,上hibernate反而是累赘
0 请登录后投票
   发表时间:2005-07-07  
由于本人刚刚接触,麻烦说详细点!
0 请登录后投票
   发表时间:2005-07-07  
现在手工:
<ww:property value="po_Line_List[0].[0]"/>
<ww:property value="po_Line_List[0][1]"/>
<ww:property value="po_Line_List[0][2]"/>
可以取得,但是怎么可以
用变量po_Line_List[i][j]方式来遍历取得。
0 请登录后投票
   发表时间:2005-07-08  
通过po_Line_List[i][j]方式
<ww:iterator value="po_Line_List" status="rowstatus">
itemCode:<ww:property value="po_Line_List[#rowstatus.Index][0]"/>
poQty:<ww:property value="po_Line_List[#rowstatus.Index][1]"/>   
itemName:<ww:property value="po_Line_List[#rowstatus.Index][2]"/>  

不要通过po_Line_List[i][j]方式来遍历取得,可以用名称方式取得?
好像***get("itemName")
0 请登录后投票
   发表时间:2005-07-14  
<ww:iterator value="messages" status="index">
   <b>Name:</b><ww:property value="name"/>
   <b>Message:</b><ww:property value="msg"/>
   <br>
</ww:iterator>
像这样直接用名字就能遍历了啊,我一直都这么做的,不知是不是有什么不妥?
0 请登录后投票
   发表时间:2005-07-15  
mindyz 写道
String sql =  "select b.itemCode,a.poQty,b.itemName from Po_Line as a ,Item as b where a.itemId=b.itemId";
List po_Line_List = getHibernateTemplate().find(sql);


jsp:
<ww:iterator value="po_Line_List" status="index">
<ww:property/>
</ww:iterator>

为什么只能取得itemCode不能取得poQty,itemName?


其实你真的这样用也可以吧, 毕竟也有时候会出现有些BT, 需要这样做的情况.
你可以先遍历, 并新建针对性的"临时的"VO来使可以通过属性名来在tag中调用
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics