|
|
在业务逻辑里,代码是这样
Query query = session.createQuery("select p,pp,pc,pac from Product as p, ProductPrice as pp, ProductContent as pc,ProductAndCategory as pac where p.productId = :productId and pp.productId=:productId and pc.productId=:productId and pac.productId = :productId");
query.setParameter("productId",productId);
List result = query.list();
Query query1 = session.createQuery("select pa.attributeValue from ProductAttribute pa where pa.attributeName = 'picName' and pa.productId = :productId");
query1.setParameter("productId",productId);
if(query1.list().isEmpty()){
attributeValue = "8c424380-6b54-4749-9d90-bf2bc3792374.gif";
}else{
Iterator it = query1.list().iterator();
while(it.hasNext()){
attributeValue = (String)it.next();
}
}
Object[] row1 = new Object[2];
//result为一个没有iterator的list对象
row1[0] = result;
row1[1] = attributeValue;
al.add(row1);
action代码为
。。。。。。。。。。。
Release release = (Release)ServiceLocator.getInstance().getService("release");
result = release.getReleaseProductInfo(productId);
。。。。。。。。。
public List getResult(){
return this.result;
}
页面的代码为:测试用的
、//进入一级遍历
<ww:iterator value="result"/>
<!--一级list的长度-->
<ww:property value="top.length"/>
//进入二级遍历
<ww:iterator value="top[0]">
<!--二级list的长度-->
<ww:property value="top.length"/>
<ww:property value="top[0].productId"/>
<ww:property value="top[1].price"/>
<ww:property value="top[2].intro"/>
<ww:property value="top[3].productId"/>
<!--在二级遍历中,取一级中的数据--加个[1],同样的道理,如果是从三级跳到一级,那就[2]
不过有个问题,如是查从-->
跳出来<ww:property value="[1].top[1]"/>
</ww:iterator>
//下面在一级目录,由于它不是list对象,是个String故不用<ww:iterator value="top[1]">
<ww:property value="top[0].productId"/>
</ww:iterator>
|
|