From Olsen Design

Jump to: navigation, search

JSP Struts 2 Interator Example

Iterate through a list and create 2 columns of data.

<table style="border: 1px solid yellow; width:100%">              
  <s:iterator status="data" value="{0,1,2,3,4}" >      
    <s:if test="#data.odd">
       <tr style="border:1px solid blue">
    </s:if>                    
    <td style="border:1px solid red">data-<s:property value="#data.index"/></td>            
    <s:if test="#data.odd"> 
      <td style="border:1px solid red"></td>
    </s:if>
    <s:if test="#data.last && #data.odd">            
      <td colspan="3" style="border:1px solid green">&nbsp;</td>                                               
    </s:if>                                          
    <s:if test="#data.even">
      </tr>
    </s:if>
  </s:iterator>
</table>