日期:2014-05-20  浏览次数:20747 次

struts 2嵌套iterator问题
我现在有一个List: List<TrainingCourseClassAttendHistory> trainingCourseClassAttendHistory;
在这个List中还有另一个集合:
public class TrainingCourseClassAttendHistory implements java.io.Serializable {
  ......
private Set<TrainingCourseClassAttendPeriod> trainingCourseClassAttendPeriod = null;
  set/get方法;
  ......
}
我现在要在JSP页面中用s:iterator遍历trainingCourseClassAttendHistory,在这个遍历中还要遍历内部的集合.....
请有经验的大师给指导一下。
<s:if test="trainingCourseClassAttendHistory!=null">
<s:iterator value="trainingCourseClassAttendHistory" status="stat">
<tr>
<td>
<s:property value="test" default=""/>
</td>
<td>
<s:property value="test" default=""/>
</td>
<td>
就是这里不知道怎么做了。
<%--<s:property value="%{trainingCourseClassAttendHistory[#stat.index].}"/>
--%>
</td>
<td>
<s:property value="%{trainingCourseClassAttendHistory[#stat.index].attendPercentage}" default="0" />
</td>
<td>
<s:property value="%{trainingCourseClassAttendHistory[#stat.index].cpdId}" default="0" />
</td>
<td>
<s:property value="%{trainingCourseClassAttendHistory[#stat.index].mpfCpdCore}" default="0" />
</td>
<td>
<s:property value="%{trainingCourseClassAttendHistory[#stat.index].mpfCpdNonCore}" default="0" />
</td>
<td>
<s:property value="%{trainingCourseClassAttendHistory[#stat.index].cpt}" default="0" />
</td>
</tr>
</s:iterator>

------解决方案--------------------
Java code

      <s:iterator value="listR" var="devil">
      <tr class=Off onMouseOut="this.className='Off'" onMouseOver="this.className='Up'">
        <td height="24"><div align="center">
            <input type="checkbox" name="id" value="<s:property value='#devil.r_id'/>" id="id">
        </div></td>
        <td><div align="center"><s:property value="#devil.r_id"/></div></td>
        <td><div align="center">
      <s:property value="#devil.r_name"/></div></td>
        <td><div align="center"><s:property value="#devil.r_depict"/></div></td>
        <td><div align="center">
            <div align="center">
            <div align="center"><s:iterator var="o" value="#devil.states"><s:property value="#o.s_name"/>、</s:iterator> </div>
            </div>
        </div></td>
        <td><div align="center"><a href="<%=basePath%>system/updaterole.jsp?id=${devil.r_id}">
        <img src="<%=basePath%>images/edit.gif" width="16" height="19" border="0"></a></div>
            <div align="center"></div></td>
      </tr>
      </s:iterator>

------解决方案--------------------
探讨
引用:

Java code

<s:iterator value="listR" var="devil">
<tr class=Off onMouseOut="this.className='Off'" onMouseOver="this.className='Up'">
<td height="24"><div align="center">