<s:iterator value="sonList" status="sList">
<tr>
<td>
<p><span class="STYLE1">${name}</span>
<span class="STYLE1"><s:property value="id" id="ssid"/></span><br>
<table width="180" height="20" border="0" cellpadding="0" cellspacing="0">
<s:iterator value="productList" id="lid" status="parser" >
<s:if test="#sList.index==1">
<!-- 迭代区 -->
<s:iterator value="lid" status="dlist" >
??????
<s:if test="#parser.index%2==0">
<tr>
</s:if>
<td height="20"> <table width="90" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="74"><A href="product_content.dhtml product.id=${id}">${name},${id},${cid}</A></td>
</tr>
</table></td>
</s:iterator>
</s:if>
</s:iterator>
其中,sonList中的对象的ID是productList对象中的外键。要在“???”附近写判断(s:if)sonList中ID,和productList中的cid相等。要怎么把sonList中的对象的ID的值在里面一层的iterator表示出来?
自己研究了很久都没做出来。请教各位高手。
谢了!
------解决方案--------------------
<s:iterator value="sonList" id="son" status="sList">
<tr>
<td>
<p> <span class="STYLE1">${name} </span>
<span class="STYLE1"> <s:property value="id" id="ssid"/> </span> <br>
<table width="180" height="20" border="0" cellpadding="0" cellspacing="0">
<s:iterator value="productList" id="lid" status="parser" >
<s:if test="#sList.index==1">
<!-- 迭代区 -->
<s:iterator value="lid" status="dlist" >
??????
<s:if test="#parser.index%2==0">
<tr>
</s:if>
<td height="20"> <table width="90" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="74"> <A href="product_content.dhtml product.id=${id}">${name},${id},${cid} </A> </td>
</tr>
</table> </td>
</s:iterator>
</s:if> 你循环的一踏糊涂啊,根本看不懂,<s:iterator value="lid" status="dlist" > 这是在循环什么,已经是对象了还怎么循环
<s:if test="${son.id == lid.id}">
</s:iterator>
------解决方案--------------------
struts2的嵌套迭代非常简单,只需照着以下代码修改一下
- HTML code
<s:iterator value="#request.listMain" id="main"> <s:property value="name"/> -- <s:property value="id"/> <s:iterator value="#listMain.details" id="detail"> <s:property value="name"/> -- <s:property value="id"/> </s:iterator> </s:iterator>