This tag is used to iterate the output of a series of objects in a Collection collection, and can specify the number of iterations. The general use format is as follows:
<c:foreach items= "collection" var= "VarName" [varstatus= "Varstatusname"][begin= "Begin"] [end= "End"] [step= "Step"] >body content</c:foreach>
The attributes used in this tag are described below:
var: the name of the object that is saved in the Collection collection class.
Items: The collection class name that will be iterated.
Varstatus: Stores the state information of an iteration and can access information about the iteration itself.
Begin: If the begin value is specified, it means that the iteration starts from Items[begin], and if no begin value is specified, the set
The first value of the hop begins the iteration.
End: Ends when iterating to the end of the collection, and if no end value is specified, represents the last of the collection in the iteration
-bit
Step: Specifies the step size of the iteration.
<%string items[] = new String[5];items[0] = "core Tag library"; Items[1] = "internationalization tag"; items[2] = "SQL Tag"; items[3] = "xml tag"; Items[4] = "Function Tag library";Request.setattribute ("items", items);%><b></b><c:out value= "does not specify the iteration of Begin:"/></b><c:foreach var= "item" items= "${items}" > <c:out value= "${item}"/><br></c:foreach><b><c:out value= "Specify the iteration of Begin and end"/>< /b><c:foreach var= "Item" items= "${items}" begin= "1" end= "3" step= "1" > <c:out value= "${item}"/><br ></c:foreach><b><c:out value= "Output information for the entire iteration"/></b><c:foreach var= "item" items= "${items} "Begin=" 3 "end=" 4 "step=" 1 "varstatus=" s "><c:out value=" ${item} "/> Four properties <br> location, index <c:out value=" ${s.index} "/><br> iterative: <c:out value=" ${s.count} "/><br> is the first location: <c:out value=" ${s.first} "/ ><br> is the last location: <c:out value= "${s.last}"/><br></c:foreach>
Jsp:foreach Label