说明
在JSO页面中,引入struts标签库
<%@ taglib uri="/struts-tags" prefix="s" %>
s:iterator标签
作用
用于遍历集合,在jsp中显示
属性
-
value:取值是一个OGNL表达式
-
var:
-
写了该属性:var的值是一个字符串,他会把var的值作为key,把当前遍历的对象作为value,存入contextMap中
-
没写该属性:把当前遍历的对象压栈,每次遍历结束后弹栈
-
-
begin:遍历的开始索引
-
end:遍历的结束索引
-
step:遍历的步长
-
status:计数器对象
-
isOdd:是否是奇数行
-
isEven:是否是偶数行
-
isFirst:是否是第一行
-
isLast:是否是最后一行
-
getCount:获取当前遍历的个数 从1开始
-
getIndex:获取当前遍历的索引 从0开始
<s:iterator value="list" var="customer">
<TR style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
<TD><s:property value="#customer.custName"/></TD>
<TD><s:property value="#customer.custLevel"/></TD>
<TD><s:property value="#customer.custSource"/></TD>
<TD><s:property value="#customer.custIndustry"/></TD>
<TD><s:property value="#customer.custAddress"/></TD>
<TD><s:property value="#customer.custPhone"/></TD>
<TD>
<a href="${pageContext.request.contextPath }/selectCustomerByCid_Customer.action?custId=${customer.custId}">修改</a>
<a href="${pageContext.request.contextPath }/customer/CustomerServlet?method=removeCustomer&custId=${customer.custId}">删除</a>
</TD>
</TR>
</s:iterator>
s:actionerror