If/elseif/else: Branch Control
Test = the logical expression used for testing. It accepts the logical operation result of 1 or 0 and uses "% {}" for calculation.
The call method is as follows:
<s:set name="month" value="8"/><s:if test=%{#month>=2&&#month<=4}>Spring</s:if><s:elseif test=%{#month>=5&&#month<=7}>Summer</s:elseif><s:elseif test=%{#month>=8&&#month<=10}>Fall</s:elseif><s:else>Winter</s:else>
Iterator: iterator
Value = the Set to be iterated, which can be List, Set, Map, or array. It is usually specified using an OGNL expression. If the value attribute is not specified, the set at the top of the ValueStack stack is used.
Id = specifies the ID of an element in the set. You can use this attribute to access a single element in the set.
Status = specifies the IteratorStatus instance during iteration to determine the attributes of the current iteration element, such as whether the iteration element is the last and the index value of the current iteration Element
The call method is as follows:
1: simple set of iterations:
<table border=1 width=200><s:iterator value="{'Friskit','20','Java EE','Struts'}" id="misc" status="sta"><tr <s:if test="#sta.odd">style="background-color:#eeeeee"</s:if>><td><s:property value="misc"/></td></tr></s:iterator></table>
2: iterate the Map object. Each key-value pair is treated as a set element when the Map object is iterated. In order to retrieve each key and value in the Map, when using the property tag, you can specify the attribute of value as value and key (different from using the id tag in the iteration set ), the Code is as follows:
<table border=1 width=200><s:iterator value="#{'Friskit':'Boy','JessicaPark':'Girl','Fem':'Boy'}" status="status"><tr <s:if test="#status.odd">style="background-color:#eeeeee"</s:if>><td><s:property value="%{#status.index+1}"/></td><td><s:property value="key"/></td><td><s:property value="value"/></td></tr></s:iterator></table>
Note: If the status label value is set for Iterator, an IteratorStatus object will be created during each iteration. The IteratorStatus class contains the following methods (getter attribute ):
Int getCount () // returns the number of elements in the current iteration int getIndex () // returns the index boolean isEven () of the element in the current iteration () // returns whether the index of the currently iterated element is an even number boolean isFirst () // returns whether the currently iterated element is the first boolean isLast () element () // returns whether the currently iterated element is the last element boolean isOdd () // returns whether the index of the currently iterated element is an odd number.