Playframework 2 java map iteration in template

I am new to playframework 2, and I would like to iterate over the card in the template, I am using java at the moment :-) Can someone please write an example? My map is similar:

Map<Integer,MyObject> 

Thank you in advance

+4
source share
2 answers

In the Play 2 template, you can iterate on a map using this syntax:

 @(myMap: Map[Integer, MyObject]) @for((key, value) <- myMap){ @key - @value } 
+11
source

Thanks so much for your answer @mguillermin. I found another that might help someone use the current index in a loop:

 @for(((key, value), currentIndex) <- myMap.zipWithIndex) { @key - @value - @currentIndex } 
+6
source

Source: https://habr.com/ru/post/1483884/


All Articles