在使用控制标签前,须要在jsp文件中引入标签html
且常常与ognl、el表达式打搭配使用web
<%@ taglib prefix="s" uri="/struts-tags" %>
属性:testapache
<!-- Action --> private String framework = "Struts2" <!-- JSP --> <s:set name="webFramework" value="framework" /> //使用了ognl表达式 <s:if test="%{#webFramework=='Struts2'}"> this is struts2 </s:if> <s:elseif test="%{#webFramework=='Struts1'}"> this is struts1 </s:elseif> <s:else> other framework </s:else>
属性jsp
-begin :从begin开始迭代(index) -end :到end结束迭代(index) -value :被迭代的集合 -id :集合中的元素的id(Struts2.1.x中已被废弃,用var来代替) -var :集合中的元素 -step :每次步长,i = i + step -status:用于在IteratorStatus类中声明名称,迭代状态
IteratorStatus类用于获取迭代的状态信息:[索引]、[计数]、[第一个]、[最后]、[奇]、[偶]等this
int getCount() 返回当前迭代了几个元素 status.count int getIndex() 返回当前元素索引 status.index boolean isFirst() 当前是否第一个元素 status.first boolean isLast() 当前是否最后元素 status.last boolean isEven() 固然的索引是否偶数 status.even boolean isOdd() 当前元素索引是否奇数 status.odd
具体例子请参照iteratorcode