Detailed Jstl of the foreach label
for loop control, it can set the collection (Collection) the members of the group are browsed through it sequentially.
??
? <c:forEach> The syntax of the tag ? Description ? :
Syntax: Iterate over all members of a collection object
<C:foreach[Var= "VarName" ] items= "collection" [varstatus= "Varstatusname" [begin=< Span style= "COLOR: #2a00ff" > "Begin" [end= "End" [ step= "Step" ]> ???????? Ontology Content </c:foreach> |
<c:forEach> Label's ? Property Description ? :
?
<c:forEach> Label's ? Properties :? varstatus property: It provides four additional properties : Index,count,fist and the Last , they have a self-meaning as follows :
Property |
Type |
Significance |
index |
number |
|
count |
number |
|
first |
boolean |
|
Last |
Boolean |
Now refers to whether the member is the last |
?
?
Example:
Servlet Code:
map<string, string> map = new hashmap<string, string> (); Map. Put ("1", "a"); Map. Put ("2", "B"); Map. Put ("3", "C"); Request. SetAttribute ("Map", map); Request. Getrequestdispatcher ("3.jsp"). Forward (request, response); |
?
JSP Code:
<C:foreachvar= "entry" Span style= "COLOR: #7f007f" >items= " ${map} " varstatus= "status" begin< Span style= "Color:black" >= "0" end= " ${map.size ()} " step= "1" > ???? Entry.key: <c:outvalue="${entry.key}"/>| ???? Entry.value: <c:outvalue="${entry.value}"/ >| ???????? ???? Status.index: <c:outvalue="${status.index}"/>| ???? Status.count: <c:outvalue="${status.count}"/>| ???? Status.first: <c:outvalue="${status.first}"/ >| ???? Status.last: <c:outvalue="${status.last}"/> ???? <br /> </C:foreach> |
?
The output is:
?
?
?
Reference documents:
JSTL label Reference Manuals
Detailed Jstl of the foreach label