Type 1: struts1.2 looping element. name indicates the result set. Reference tag library <% @ taglib uri = "http://struts.apache.org/tags-logic" prefix = "logic" %>
[Java]
<Logic: iterate id = "x" name = "alluser">
<Tr>
<Td >$ {x. u_id} </td>
<Td >$ {x. u_name} </td>
<Td >$ {x. u_sex} </td>
<Td> <a href = "$ {pageContext. request. contextPath}/user. do? Method = one & u_id =$ {x. u_id} "> modify </a> </td>
<Td> <a href = "$ {pageContext. request. contextPath}/user. do? Method = del & u_id =$ {x. u_id} "> Delete </a> </td>
</Tr>
</Logic: iterate>
Type 2: struts2.0 looping element. Note: value is the result set. Reference the tag library <% @ taglib uri = "/struts-tags" prefix = "s" %>
[Java]
<S: iterator value = "allemp" status = "all">
<Tr>
<Td> <s: property value = "# all. getIndex () + 1"/> </td>
<Td >$ {EId} </td>
<Td >$ {EName} </td>
<Td >$ {TDept. PName} </td>
<Td>
<S: if test = "# this. ESex = 1"> male </s: if>
<S: else> female </s: else>
</Td>
<Td >$ {ELove} </td>
<Td> <a href = "$ {pageContext. request. contextPath}/emp! One. action? E_id =$ {EId} "> modify </a> </td>
<Td> <a href = "$ {pageContext. request. contextPath}/emp! Del. action? E_id =$ {EId} "> Delete </a> </td>
</Tr>
</S: iterator>
Third: serlvet uses the <c:> tag loop traversal. Note: items is the result set. Reference tag library <% @ taglib prefix = "c" uri = "/WEB-INF/c. tld" %>
[Java]
<C: forEach var = "x" items = "$ {all}">
<Tr>
<Td id = "title" colspan = "2"> title: $ {x. n_title} </td>
</Tr>
<Tr>
<Td colspan = "2"> author: $ {x. n_user} td>
</Tr>
</C: forEach>