How to iterate over map using mustache in java

I don't know mustache but basing on some samples of code I have seen, I think you should define an entrySet variable in your Java code like this

Set<Map.Entry<String,Object>> entrySet = mapA.entrySet();

and use it instead of mapA in your mustache code

{{#entrySet}}
  <li>{{key}}</li>
  <li>{{value}}</li>
{{/entrySet}}

it is much simpler than that, just do it like this:

{{#mapA}}
  {{#entrySet}}
    <li>{{key}}</li>
    <li>{{value}}</li>
  {{/entrySet}}
{{/mapA}}

Tags:

Java

Mustache