2011-08-16 47 views
-2
<table> 
<c:forEach items="${requestScope['rfpq.mailRecievers']}" var="row"> 
<tr> 
              <td>&nbsp; </td> 
<td style="color: #000000; font-size: 11px;" height="17" width="450"> &nbsp;${row} |</td> 

</tr> 
</c:forEach> 
</table> 

输入是:我怎样才能获得通过侧输入侧JSP

A0001 |

A0002 |

A0003 |

A0004 |

A0005 |

我将如何得到输入像(颜色):

A0001 | (颜色:灰色)A0002 | A0003 | (颜色:灰色)A0004

回答

2
<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"> &nbsp;${row} |</td> 
       </c:when> 
       <c:otherwise> 
        <td style="color: gray; font-size: 11px;" height="17"> &nbsp;${row}|</td> 
       </c:otherwise> 
      </c:choose> 
     </c:forEach> 
    </tr> 
</table> 

可以使用varStatus属性来访问LoopTagStatus实例当前<c:forEach>,其count财产给你循环计数器。你可以使用这个循环计数器来设置你的奇数列和偶数列的样式。

+0

我已经试过这个,但是当我写这个时我的表炸弹。 –

+0

另外我写道:

有同样的问题,表炸弹。 –

+0

看来,你想风格的奇数列甚至列,只是更新 –