logic:iterate=>c:forEach

strutsタグを順次JSTLに移行しよう極秘計画を遂行中。

logic:iterateでの記述

<logic:iterate id="hoge" name="hogeBean" property="hogeList" scope="session">
  <TR bgcolor="#FFFFEE">
    <TD nowrap width="10%" align="center">
      <bean:define id="groupIndex" name="hoge" property="index" />
      <html:radio property="index" value="<%= groupIndex.toString() %>" />
    </TD>
    <TD nowrap>
      <bean:write name="hoge" property="name" />
    </TD>
  </TR>
</logic:iterate>


session上のbeanにあるList hogeListをiterateして、そのindexを選択してPOSTしようという画面。


これをJSTLで書き直すと。

<c:forEach var="hoge" items="${hogeBean.hogeList}" varStatus="status">
  <TR bgcolor="#FFFFEE">
    <TD nowrap width="10%" align="center">
      <html:radio property="index" value="${status.index}" />
    </TD>
    <TD nowrap>
      <c:out value="${hoge.name}"/>
    </TD>
  </TR>
</c:forEach>


以上、終わり!