Reputation: 35
I need to send the data which is present in a list from my spring controller to thymeleaf (html) how can I send the data? after receiving how can I iterate the data in thymeleaf
Upvotes: 2
Views: 1388
Reputation: 25613
Put your list inside your ModelMap
or ModelAndView
object then traverse it using th:each
within your thymeleaf page.
From Java side:
modelMap.addAttribute("list", myListOfThings);
From Thymeleaf side:
<ul>
<li th:each="item : ${list}">
<span th:text="${item}">Default</span>
</li>
</ul>
Upvotes: 2