Struts逻辑:迭代列表列表

时间:2013-11-15 21:39:32

标签: java jsp struts

我试图迭代一个有另一个类作为成员变量的类。以下是该类的一些代码:

public class UnregisteredCaseRecipient extends Auditable {

private String peoplePin;
private String recipName;
private String roleCd;
private String secLvl;
private List<UnregisteredCaseRecipientNotification> unregisteredCaseRecipientNotifications;

我尝试过的JSP代码如下:

                        <logic:iterate name="caseRecip" id="unregisteredCaseRecipientNotifications">
                                <td style="width: 25px;">
                                    <input type="checkbox" name="docRecipNotify" id="docRecipNotify" value="${unregisteredCaseRecipientNotifications.id}" ${unregisteredCaseRecipientNotifications.notificationCheck}/>
                                </td>
                        </logic:iterate>

我尝试过与this相似的东西但没有运气。

<nested:iterate id="unregisteredRecipients" name="crFilingServiceListForm" property="unregisteredCaseRecipients" >
                                    <nested:iterate id="unregisteredCaseRecipientNotifications" name="unregisteredRecipients">
                                        <td style="width: 25px;">notify: ${unregisteredCaseRecipientNotifications.notify} id: ${unregisteredCaseRecipientNotifications.id}
                                            <input type="checkbox" name="docRecipNotify" id="docRecipNotify" value="${unregisteredCaseRecipientNotifications.id}" ${unregisteredCaseRecipientNotifications.notificationCheck}/>
                                        </td>
                                    </nested:iterate>   
                                </nested:iterate>

我也试过像this这样的东西而没有运气。

                        <logic:iterate name="crFilingServiceListForm" property="${caseRecip.unregisteredCaseRecipientNotifications" id="caseRecipNotify" indexId="j">
                                <td style="width: 25px;">
                                    <input type="checkbox" name="docRecipNotify" id="docRecipNotify" value="${caseRecipNotify.id}" ${caseRecipNotify.notificationCheck}/>
                                </td>
                        </logic:iterate>

谢谢,

汤姆

2 个答案:

答案 0 :(得分:2)

我能够通过使用嵌套for来实现这一点:

<c:forEach items="${crFilingServiceListForm.unregisteredCaseRecipients}" var="unregisteredRecip">
    <c:forEach items="${unregisteredRecip.unregisteredCaseRecipientNotifications}" var="unregisteredNotification">
    <td style="width: 25px;">
        <input type="checkbox" name="docRecipNotify" id="docRecipNotify" value="${unregisteredNotification.id}" ${unregisteredNotification.notificationCheck}/>
    </td>
    </c:forEach>
    </tr>
</c:forEach>

感谢大家的帮助!

汤姆

答案 1 :(得分:-1)

试试这个:

<logic:iterate name="unregisteredCaseRecipientList" id="unregisteredCaseRecipient">
    <logic:iterate name="unregisteredCaseRecipient" property="unregisteredCaseRecipientNotifications" id="unregisteredCaseRecipientNotification">
        <td style="width: 25px;">
            <input type="checkbox" name="docRecipNotify" id="docRecipNotify" value="${unregisteredCaseRecipientNotification.id}" ${unregisteredCaseRecipientNotification.notificationCheck}/>
        </td>
    </logic:iterate>
</logic:iterate>

否则,您可以使用<bean:write/>代替$ {}

祝你好运!