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>