How can use data List<Map<String, String>> in template?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can use data List<Map<String, String>> in template?

Howard Seo
Hi, I got data from legacy like below
ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
                list.add(new HashMap<String, String>() {{
                                put("name", "howard");
                                put("age", "33");
                        }
                });
                list.add(new HashMap<String, String>() {{
                                put("name", "john");
                                put("age", "22");
                        }
                });
                list.add(new HashMap<String, String>() {{
                                put("name", "kim");
                                put("age", "30");
                        }
                });

And I'd like to display it like below.
<ul>
    <li>howard - 33</li>
    <li>john - 22</li>
    <li>name - kim</li>
</ul>

Is there a way to use map data from list collections?
Reply | Threaded
Open this post in threaded view
|

Re: How can use data List<Map<String, String>> in template?

eiryu
My anticipation is this.

<ul>
  <li th:each="map : ${list}" th:text="${map['name']}+ ' - '+ ${map['age']}">howard - 33</li>
</ul>
Reply | Threaded
Open this post in threaded view
|

Re: How can use data List<Map<String, String>> in template?

Howard Seo
This works for me.

Thx. eiryu