title: How to print Array size in thymeleaf?
body: <p>I'm using <strong>Thymeleaf</strong> with <strong>spring mvc 4</strong> but I have a problem when I want to print a list size</p>
  <pre class="lang-html prettyprint-override"><code>&lt;tr th:each=&quot;u : ${users}&quot; th:id=&quot;${u.username}&quot; class=&quot;odd gradeX&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;td th:text=&quot;${u.username}&quot;&gt;&lt;/td&gt;
      &lt;td th:text=&quot;${u.email}&quot;&gt;&lt;/td&gt;
      &lt;td th:switch=&quot;${u.enabled}&quot;&gt;
          &lt;span th:case=&quot;true&quot; class=&quot;badge badge-primary&quot;&gt;Acitf&lt;/span&gt;
          &lt;span th:case=&quot;false&quot; class=&quot;badge badge-danger&quot;&gt;Désactivée&lt;/span&gt;
          &lt;span th:case=&quot;*&quot; class=&quot;badge badge-dark&quot;&gt;Inconnue&lt;/span&gt;
      &lt;/td&gt;
      &lt;td th:switch=&quot;${u.roles}&quot;&gt;
          &lt;span th:case=&quot;ROLE_SUPER_ADMIN&quot;&gt;Super ADmin&lt;/span&gt;
          &lt;span th:case=&quot;ROLE_MANGER&quot;&gt;Manager&lt;/span&gt;
          &lt;span th:case=&quot;ROLE_SUPERVISEUR&quot;&gt;Superviseur&lt;/span&gt;
          &lt;span th:case=&quot;ROLE_USER&quot;&gt;User&lt;/span&gt;
          &lt;span th:case=&quot;*&quot;&gt;Inconnue&lt;/span&gt;
  
      &lt;/td&gt;
      &lt;td th:text=&quot;${#calendars.format(u.creationDate,'dd/MM/yyyy hh:mm')}&quot;&gt;&lt;/td&gt;
      &lt;td th:text=&quot;${#calendars.format(u.lastLogin,'dd/MM/yyyy hh:mm')}&quot;&gt;&lt;/td&gt;
      **
      &lt;td th:text=&quot;${u.engines}&quot;&gt;&lt;/td&gt;
      &lt;td th:text=&quot;${u.subordonnes}&quot;&gt;&lt;/td&gt;
      **
      &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  <p>the problem is here <code>th:text=&quot;${u.engines}&lt;/td&gt;</code>. <code>engines</code> is an ArrayList in my <code>User</code> entity. I tried <code>th:size</code> and <code>th:list</code> but it didn't work.</p>
  <p>Can anyone help me please</p>
  <h2>Edited</h2>
  <p>here is my <code>User</code> entity:</p>
  <pre><code>@OneToMany(mappedBy = &quot;superieur&quot;)
  @JsonIgnore
  private List&lt;User&gt; subordonnes = new ArrayList&lt;User&gt;();
  
  @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  @JoinTable(name = &quot;USERS_ENGINES&quot;, joinColumns = @JoinColumn(name = &quot;USER_ID&quot;), inverseJoinColumns = @JoinColumn(name = &quot;NUM_EQUIPMENT&quot;))
  @JsonIgnore
  private List&lt;Engine&gt; engines = new ArrayList&lt;Engine&gt;();
  </code></pre>
  <p>and my Controller method:</p>
  <pre><code>@RequestMapping(value = {&quot;/listeUsers&quot;})
  public ModelAndView userlistePage() {
      ModelAndView model = new ModelAndView();
      User logedUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      
      List&lt;User&gt; users = new ArrayList&lt;User&gt;();
      users = userService.findUserSub(logedUser);
      model.addObject(&quot;users&quot;, users);
      model.setViewName(&quot;utilisateur/list_users&quot;);
      return model;
  }
  </code></pre>