Simple demo:
s:iterator tag has 3 attributes:
value: the collection to be iterated
id: the id of the element in the specified collection
status the index of the iterated element
1: jsp page definition element writing method array or list
The printed result is: 1A2A3A4A5A
2: Index usage
If status is specified, each iteration data has an instance of IteratorStatus, which has the following methods
int getCount( ) Returns how many elements are currently iterated
int getIndex() Returns the current element index
boolean isEven() Of course, whether the index is even Whether the index is odd
The current index is an odd number:
Current element value:
3: Traverse the map
value can be directly defined as:
value="#{"1":"a","2":"b"}"
each Elements are separated by good distances. The key and value between elements are separated by colons
value can also be the java.util.Map object in the data stack
The traversal is written as follows:
key :
value:
Of course both key and value can be used Use java's Object
3: Traverse the data stack. Simple List class,
List
class Attr{String attrName;String getAttrName(){return "123";}}
Of course value can also be written as value="%{label}" label can have .To operate the attribute List of
label, you can write it as value="%{label.list}", which is equivalent to: getLabel().getList();
4: Traverse 2 lists;
List
List
The elements of these two lists are in one-to-one correspondence, one attrN corresponds to one attrV
index is :
attrName is :
attrName is :
counter:
This tag is the main The function is to iterate out the collection. .
The value attribute indicates the value that needs to be displayed.