- <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 }">修改</a></td>
- <td><a href="${pageContext.request.contextPath }/user.do?method=del&u_id=${x.u_id }">删除</a></td>
- </tr>
- </logic:iterate>
<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 }">修改</a></td>
<td><a href="${pageContext.request.contextPath }/user.do?method=del&u_id=${x.u_id }">删除</a></td>
</tr>
</logic:iterate>
第二种:struts2.0循环遍历元素,注:value是结果集。引用标签库<%@ taglib uri="/struts-tags" prefix="s" %>
- <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">男</s:if>
- <s:else>女</s:else>
- </td>
- <td>${ELove }</td>
- <td><a href="${pageContext.request.contextPath }/emp!one.action?e_id=${EId }">修改</a></td>
- <td><a href="${pageContext.request.contextPath }/emp!del.action?e_id=${EId }">删除</a></td>
- </tr>
- </s:iterator>
<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">男</s:if>
<s:else>女</s:else>
</td>
<td>${ELove }</td>
<td><a href="${pageContext.request.contextPath }/emp!one.action?e_id=${EId }">修改</a></td>
<td><a href="${pageContext.request.contextPath }/emp!del.action?e_id=${EId }">删除</a></td>
</tr>
</s:iterator>
第三种:serlvet用<c:>标签循环遍历,注:items是结果集。引用标签库<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
- <c:forEach var="x" items="${all}">
- <tr>
- <td id="title" colspan="2">标题:${x.n_title }</td>
- </tr>
- <tr>
- <td colspan="2">作者:${x.n_user }td>
- </tr>
- </c:forEach>
<c:forEach var="x" items="${all}">
<tr>
<td id="title" colspan="2">标题:${x.n_title }</td>
</tr>
<tr>
<td colspan="2">作者:${x.n_user }td>
</tr>
</c:forEach>