title: Thymeleaf ModelAttribute List
body: <p>I try to have something like a List as a ModelAttribute with Thymeleaf, but I do not get it to work. I read this page <a href="http://www.bincsoft.com/blog/thymeleaf-and-lists-in-forms/" rel="nofollow noreferrer">http://www.bincsoft.com/blog/thymeleaf-and-lists-in-forms/</a> but my code fails.</p>
  
  <p>here are my files:</p>
  
  <p><strong>container class</strong></p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  import javax.validation.Valid;
  
  
  public class WagerateForm {
  
      @Valid
      private List&lt;WagerateUi&gt; wagerateuilist;
  
      public WagerateForm() {
          wagerateuilist = new ArrayList&lt;WagerateUi&gt;();
      }
  
      public WagerateForm(List&lt;WagerateUi&gt; wagerateuilist) {
          this.wagerateuilist = wagerateuilist;
      }
  
      //getter , setter omitted
  }
  </code></pre>
  
  <p><strong>my DTO for ui</strong></p>
  
  <pre><code>public class WagerateUi {
  
      //getter , setter omitted
  
      private boolean standard;
      private Long value;
  }
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>@Named
  @RequestMapping("/wagerate")
  public class WagerateController {
  
  @RequestMapping(value="")
  public String wagerate(@ModelAttribute("wagerateform") WagerateForm wagerateForm,
          BindingResult bindingResult) {
  
      List&lt;WagerateUi&gt; wagerateUiList = wagerateForm.getWagerateuilist();
  
      System.out.println(wagerateUiList.size());
  
      //dummy items
      for (int i = 0; i &lt; 10; i++) {
          WagerateUi temp = new WagerateUi();
          temp.setValue(100L);
          wagerateUiList.add(temp);
      }
  
  
      return "wagerate";
  }
  </code></pre>
  
  <p><strong>thymeleaf html</strong></p>
  
  <pre><code>&lt;form id="wagerateform" class="form-horizontal" role="form" action="#" th:object="${wagerateform}" th:action="@{/wagerate}" method="post"&gt;              
  
      &lt;div th:each="wagerateui, iterStat  : ${wagerateform.wagerateuilist}"&gt;      
          &lt;input th:field="*{wagerateform[__${iterStat.index}__].value}" class="form-control"&gt;
      &lt;/div&gt;
      &lt;button type="submit"&gt;Test&lt;/button&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>error message</strong></p>
  
  <pre><code>Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'wagerateform[0]' of bean class [WagerateForm]: Bean property 'wagerateform[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
      at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:725)
      at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:571)
      at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:548)
      at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:714)
      at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
      at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:229)
      at org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:120)
      at org.thymeleaf.spring4.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:348)
      at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:288)
      at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:260)
  </code></pre>
  
  <p>The size of the list in the controller is always 0. I cant see whats wrong, i tried different ways, but I think my Thymeleaf/Spring EL is wrong. </p>