title: How to display the collection of objects with for each loop in Thymeleaf?
body: <p>I want to display data from database in the browser with Spring MVC. Everything is alright, except my Thymeleaf template for each loop. Something is wrong there.</p>
  
  <p>How can I display <code>id</code> data in <strong>ID</strong> row and <code>name</code> data in <strong>Name</strong> row iterating through the collection of objects with <em>for each</em> loop?</p>
  
  <p>Source code:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
       &lt;title&gt;Getting Started: Serving Web Content&lt;/title&gt;
       &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;table border="1"&gt;
          &lt;tr style="font-size: 13"&gt;
              &lt;td&gt;ID&lt;/td&gt;
              &lt;td&gt;Name&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr th:each="count :  ${id}"&gt;
              &lt;td&gt;&lt;p th:text="${count}" /&gt;&lt;/td&gt;       
              &lt;td&gt;&lt;p th:text="${name}" /&gt;&lt;/td&gt;        
  
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>