title: How to iterate array list in Thymeleaf template?
body: <p>I am trying to write out items from array list and make a checkboxes from them. What is wrong with this template?</p>
  
  <p>Template <strong>grant_access.html</strong></p>
  
  <pre><code>&lt;form action="#" th:action="@{/accounts/grant_access}" th:object="${request}" method="post"&gt;
          &lt;div th:each="scope:${request.requestScopes}" class="checkbox"&gt;
              &lt;label&gt;
                  &lt;input type="checkbox" value="${scope.id}" /&gt;&amp;nbsp;${scope.scope}
  
              &lt;/label&gt;
          &lt;/div&gt;
          &lt;button type="submit" name="action" value="authorize" class="btn btn-default"&gt;Authorize&lt;/button&gt;
          &lt;button type="submit" name="action" value="cancel" class="btn btn-link"&gt;Cancel&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>This is the <strong>output</strong>, codes are not translated into values.</p>
  
  <pre><code>&lt;form action="/restapi/accounts/grant_access" method="post"&gt;
      &lt;div class="checkbox"&gt;
          &lt;label&gt;
              &lt;input type="checkbox" value="${scope.id}" /&gt;&amp;nbsp;${scope.scope}
          &lt;/label&gt;
      &lt;/div&gt;
      &lt;button type="submit" name="action" value="authorize" class="btn btn-default"&gt;Authorize&lt;/button&gt;
      &lt;button type="submit" name="action" value="cancel" class="btn btn-link"&gt;Cancel&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is a <strong>controller</strong> and request object:</p>
  
  <pre><code>    @RequestMapping(value = "/grant_access", method = RequestMethod.GET)
      public ModelAndView authorize(HttpServletRequest httpServletRequest) {
  
  List&lt;Scope&gt; scopes = scopeService.getRequestedScopes(authorizationRequest.getScope());
  
          GrantRequest request = new GrantRequest();
          request.setAccount(account);
          request.setClient(client);
          request.setRequestScopes(scopes);
  
          ModelAndView modelAndView = new ModelAndView("grant_access");
          modelAndView.addObject("request", request);
  
          return modelAndView;
  }
  </code></pre>
  
  <p>and GrantRequest class:</p>
  
  <pre><code>public class GrantRequest {
  
      private Account account;
      private Client client;
      private ArrayList&lt;Long&gt; scopeIds;
      private List&lt;Scope&gt; requestScopes;
  // getters and setters omitted...
  
  }
  </code></pre>