<table>
<c:forEach items="${requestScope['rfpq.mailRecievers']}" var="row">
<tr>
<td> </td>
<td style="color: #000000; font-size: 11px;" height="17" width="450"> ${row} |</td>
</tr>
</c:forEach>
</table>
Input is:
A0001 |
A0002 |
A0003 |
A0004 |
A0005 |
How will I get input like(with colors):
A0001 开发者_开发百科| (color: gray) A0002 | A0003 | (color: gray) A0004
<table>
<tr>
<c:forEach items="${requestScope['rfpq.mailRecievers']}" var="row" varStatus="status" >
<c:choose>
<c:when test="${status.count%2==0}">
<td style="color: #000000; font-size: 11px;" height="17"> ${row} |</td>
</c:when>
<c:otherwise>
<td style="color: gray; font-size: 11px;" height="17"> ${row}|</td>
</c:otherwise>
</c:choose>
</c:forEach>
</tr>
</table>
You can use the varStatus
attribute to access the LoopTagStatus instance for the current <c:forEach>
, and its count
property gives you the loop counter. The you can use this loop counter to style your odd column and even column.
精彩评论