How to check if list of objects contains a String using thymeleaf?
<p>Say if I have an ArrayList with user objects into it. </p>

<p>User.java</p>

<pre><code>class User{
  private Long id;
  private String name;
}
</code></pre>

<p>I have a list with users</p>

<pre><code>list.add(new User(1,"John");
list.add(new User(2,"Sam");
</code></pre>

<p>I want to check in thymeleaf if user List is having a user with name "Sam".</p>

<pre><code>${#lists.contains(userList.name,'Sam')}
</code></pre>

<p>But the above doesn't work and throws <code>Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression</code></p>

<p>I've also tried with &quot; (doube-quotes)</p>