Is there any way to use 2 variables in foreach loop ?
#foreach( $name in $names && $method in $methods )
$name : $method
#end
Because I want to print the result side by side
Is there any way to use 2 variables in foreach loop ?
#foreach( $name in $names && $method in $methods )
$name : $method
#end
Because I want to print the result side by side
Just loop over an index.
Assuming both collections have the same size:
#set($size = $names.size - 1)
#foreach( $i in [0..$size])
$names[$i] : $methods[$i]
#end
(edited for correctness)
I found the solution, just put in the Map
Map<String, String> maps = new HashMap<>();
ctx.put("rows", maps);
and iterate over key in maps
#foreach( $key in $rows.keySet() )
Key: $key Value: $rows.get($key)
#end