1

consider db returns like this

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> 

this will let me too have o/p like this

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

for every date so instead i would like to print like this

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

how can i iterate in it?

4

1 回答 1

1

Try using <c:if> to check if the current row is printing out data for the same student as in the row that comes just before it. You may also use <c:otherwise> to implement an else block and print something else in the <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>
于 2013-05-18T06:13:52.437 回答