gpt4 book ai didi

java - 我可以在struts 1的逻辑迭代中循环吗?

转载 作者:太空宇宙 更新时间:2023-11-04 07:37:29 27 4
gpt4 key购买 nike

考虑像这样的数据库返回

roll-no:10csu001 student_name:aravind presentabsent:p,p,p,p date:10/4/2013 
roll-no:10csu001 student_name:aravind presentabsent:p,p,p,p date:11/4/2013
roll-no:10csu002 student_name:azhar presentabsent:p,p,a,p date:10/4/2013
roll-no:10csu002 student_name:azhar presentabsent:p,p,a,p date:11/4/2013
<小时/>
<logic:iterate id="vStudentList" name="reqStudentAttendanceList" 
type="form.StudentForm" scope="request" indexId="i" >
<td>
<span>
<bean:write name="vStudentList" property="roll_no"/>
</span>
</td>
<td>
<span>
<bean:write name="vStudentList" property="student_name"/>
</span>
</td>
<td>
<span>
<bean:write name="vStudentList" property="presentabsent"/>
</span>
</td>

这会让我也有这样的o/p

10csu001 aravind p,p,p,p 10/4/2013 
10csu001 aravind p,p,p,p 11/4/2013

对于每个日期,所以我想像这样打印

10csu001 aravind p,p,p,p 10/4/2013 
p,p,p,p 11/4/2013

我如何迭代它?

最佳答案

尝试使用<c:if>检查当前行是否正在打印与其前一行相同的学生的数据。您也可以使用<c:otherwise>实现else阻止并打印 <span> 中的其他内容.

<logic:iterate id="vStudentList" name="reqStudentAttendanceList" 
type="form.StudentForm" scope="request" indexId="i" >
<td>
<span>
<c:if test="${i > 1 && reqStudentAttendanceList[i-1].roll_no != reqStudentAttendanceList[i-2].roll_no}">
<bean:write name="vStudentList" property="roll_no"/>
</c:if>
</span>
</td>
<td>
<span>
<c:if test="${i > 1 && reqStudentAttendanceList[i-1].student_name != reqStudentAttendanceList[i-2].student_name}">
<bean:write name="vStudentList" property="student_name"/>
</c:if>
</span>
</td>
<td>
<span>
<bean:write name="vStudentList" property="presentabsent"/>
</span>
</td> <td>
<span>
<bean:write name="vStudentList" property="date"/>
</span>
</td>
</logic:iterate>

关于java - 我可以在struts 1的逻辑迭代中循环吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620969/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com