Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to iterate list, map, map of map in jstl?


Asked by Wren Paul on Dec 07, 2021 FAQ



Lets see how to iterate List using JSTL forEach loop. Using below code you can iterate ArrayList, Vector or LinkedList. 2. Map Iterate Maps like HashMap, Hashtable, TreeMap or LinkedHashMap. 3. List of Map How to Iterate List of Map ? 4. Map of List Note: You may get below exceptions if you do not provide proper value in items section.
Indeed,
Fortunately, JSTL provides you with two useful actions for looping and iteration: for general data and for a string of tokens. The <c:forEach> action is very useful.
Keeping this in consideration, The Iterable interface provides forEach() method to iterate over the List. It is available since Java 8. It performs the specified action for each element until all elements have been processed or the action throws an exception. It also accepts Lambda expressions as a parameter.
Consequently,
JSTL forEach tag is used to iterate over a collection of data . It can be Array, List, Set, ArrayList, HashMap or any other collection type.It is commonly use to render a tabular data in our web pages in form of HTML table.A common use of c:forEach is to produce a HTML table containing data gathered from a SQL query or other data source.
In respect to this,
The varStatus attribute is optional. the varStatus attribute is an instance of a class which implements interface LoopTagStatus. The varStatus attribute provides a set of useful properties to work with such as begin, end, current, index, and count. Let’s take a look at an example: