& Lt; c: forEach & gt; label, foreach label

Source: Internet
Author: User

<C: forEach> label and foreach label

<C: forEach> A tag is used for general data loops. It has the following attributes:

Genus Description Required? Default Value
Items Cyclic Project No None
Begin Start Condition No 0
End End Condition No The last project in the collection.
Step Step Size No 1
Var Variable name of the current project No None
VarStatus Variable that shows the loop status No None

VaStatus attributes

The varStatus attribute in JSTL is the same as the varStatus attribute. varStatus is used to create a variable with a limited scope. However, the variable named by the varStatus attribute does not store the current index value or the current element, but is assigned to an instance of the javax. servlet. jsp. jstl. core. LoopTagStatus class. This class defines a set of features that describe the current state of iteration. These features are listed below:

Feature Getter description current getCurrent () index getIndex () index of the current iteration (in the Set) current iteration index from 0 count getCount () first isFirst () indicates whether the current iteration is the first iteration () indicates whether the current iteration is the sign of the last iteration. The begin getBegin () begin attribute value end getEnd () end attribute value step getStep () step Attribute Value

Use the vaStatus attribute in c: forEach to obtain the iteration status, for example:
<C: forEach var = "" items = "" varStatus = "status">
<C: out value = "$ {status. current}"/> current object
<C: out value = "$ {status. index}"/> index of this iteration
<C: out value = "$ {status. count}"/> number of iterations
<C: out value = "$ {status. first}"/> whether it is the first iteration object
<C: out value = "$ {status. last}"/> whether it is the last iteration object
</C: forEach>

<C: forEach> the items attribute of the tag supports all standard set types provided by the Java platform. In addition, you can use this operation to iterate elements in an array (including an array of basic types. It supports the following Collection types and iteration elements:

Java. util. Collection: Elements obtained by calling iterator.

Java. util. Map: the Instance obtained through java. util. Map. Entry.

Java. util. Iterator: Iterator element.

Java. util. Enumeration: Enumeration element.

Object instance array: array element.

Basic Type value array: Elements of the encapsulated array.

String to be separated by commas (,): The Sub-String after segmentation.

Javax. servlet. jsp. jstl. SQL. Result: The row obtained by the SQL query.

 

From: http://www.cnblogs.com/draem0507/archive/2012/09/24/2699745.html

--

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.