title: How to populate a simple table with thymeleaf in spring mvc
body: <p>I have a list of objects and I want to display the values of those objects in a table using <code>thymeleaf</code>, this is what I have so far:</p>
  
  <p>Here is my controller class that adds my list of objects:</p>
  
  <pre class="lang-java prettyprint-override"><code>@RequestMapping(value = "/showTableWithValues", method = RequestMethod.GET)
      public String showTableWithValues(Model model) 
      {
          //list with Persons
          ArrayList&lt;Persons&gt;  personsList= 
                  new ArrayList&lt;Persons&gt;();
  
          personsList=  this.getListOfPersons();
  
          model.addAttribute("list", personsList);
  
          return "showTableWithValues";
      }
  </code></pre>
  
  <p>This is my .html file where i want to show my values:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html lang="en"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:th="http://www.thymeleaf.org"&gt;
  
  &lt;head&gt;
      &lt;title&gt;Home&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;
      Show Values 
  &lt;/h1&gt;
  
  &lt;table class="table table-striped"&gt;
                  &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;ID&lt;/th&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Cost&lt;/th&gt;
                      &lt;th&gt;Mins to prepare&lt;/th&gt;
                      &lt;th&gt;Action&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
  
                      &lt;tr th:each="persons : ${list}"&gt;
  
                      &lt;/tr&gt;   
  
                  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>And my <code>Person.java</code> class:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Person {
  
  private String name;
  private String last_name;
  private String nickname;
  
  
  
  .....get,setters and constructor
  }
  </code></pre>