How to display list of map values in HTML5 using thymeleaf -


i need display values in map in html using thymeleaf. here java code

list<object> searchresultslist = searchservice.searchperson(id);  list<string> list = new arraylist<string>(); map<integer, list<string>> mapresults = new hashmap<integer, list<string>>(); (int = 0,; < searchresultslist.size(); i++) {          list.add(0, row[0].tostring());         list.add(1, row[1].tostring());         list.add(2, row[2].tostring());      mapresults.put(i, list); } model.addattribute("mapresults", mapresults);  

html code:

<div  th:if="!${#maps.isempty(mapresults)}">     <div>     found list of  records       </div>     <table class="tg">         <thead>             <tr>                  <th class="tg"># of lines</th>                  <th class="tg">person id</th>                 <th class="tg">sub id </th>                          </tr>         </thead>             <tbody>             <tr th:each="row : ${mapresults}">                  <td class="tg bg" th:text="${row.value}"></td>                  <td class="tg bg" th:text="${row.value}"></td>                  <td class="tg bg" th:text="${row.value}"></td>              </tr>          </tbody>     </table> </div> 

actual output :

# of lines          person id           sub id    [2, 1235, 1]        [2, 1235, 1]        [2, 1235, 1] 

expected output :

# of lines          person id           sub id    2                   1235                1 

can me how retrieve each value list.

thanks in advance.

row.value list. specific item it, use item's index:

<tr th:each="row : ${mapresults}">      <td class="tg bg" th:text="${row.value[0]}"></td>      <td class="tg bg" th:text="${row.value[1]}"></td>      <td class="tg bg" th:text="${row.value[2]}"></td>  </tr>  

Comments