title: [Failed to convert property value of type 'java.lang.String[]' to required type 'java.util.List' for property
body: <p>I am working with Thymeleaf and trying to do some object binding, but I do not know how to do it if I have an object with a list. Let me explain:</p>
  
  <p>My model:</p>
  
  <pre><code>@Entity
  public class Project {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      private String name;
  
      @NotNull
      @Lob
      private String description;
  
      @NotNull
      private Date startDate;
  
      private String status;
  
      @ManyToMany
      private List&lt;Role&gt; rolesNeeded;
  
      @ManyToMany
      private List&lt;Collaborator&gt; collaborators;
  
      public Project() {
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  
      public List&lt;Role&gt; getRolesNeeded() {
          return rolesNeeded;
      }
  
      public void setRolesNeeded(List&lt;Role&gt; rolesNeeded) {
          this.rolesNeeded = rolesNeeded;
      }
  
      public List&lt;Collaborator&gt; getCollaborators() {
          return collaborators;
      }
  
      public void setCollaborators(List&lt;Collaborator&gt; collaborators) {
          this.collaborators = collaborators;
      }
  }
  </code></pre>
  
  <p>My html form:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form method="post" action="addproject" th:object="${project}"&gt;
      &lt;div&gt;
          &lt;label for="project_name"&gt; Project Name:&lt;/label&gt;
          &lt;input th:field="*{name}" type="text" name="project_name"/&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label for="project_description"&gt;Project Description:&lt;/label&gt;
          &lt;textarea th:field="*{description}" rows="4" name="project_description"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label for="project_status"&gt;Project Status:&lt;/label&gt;
          &lt;div class="custom-select"&gt;
              &lt;span class="dropdown-arrow"&gt;&lt;/span&gt;
              &lt;select th:field="*{status}" name="project_status"&gt;
                  &lt;option value="active"&gt;Active&lt;/option&gt;
                  &lt;option value="archived"&gt;Archived&lt;/option&gt;
                  &lt;option value="not_started"&gt;Not Started&lt;/option&gt;
              &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label for="project_roles"&gt;Project Roles:&lt;/label&gt;
          &lt;ul class="checkbox-list"&gt;
              &lt;li th:each="role : ${roles}"&gt;
                  &lt;input th:field="*{rolesNeeded}" type="checkbox" name="project_roles" th:value="${role}"/&gt;
                  &lt;span class="primary" th:text="${role.name}"&gt; Developer&lt;/span&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;div class="actions"&gt;
          &lt;input type="submit" value="Save" class="button"/&gt;
          &lt;a href="#" class="button button-secondary"&gt;Cancel&lt;/a&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I am getting the error:</p>
  
  <blockquote>
    <p>ERROR!!!!: Field error in object 'project' on field 'rolesNeeded':
    rejected value
    [com.imprender.instateam.model.Role@145d6cd4,com.imprender.instateam.model.Role@73020d6f];
    codes
    [typeMismatch.project.rolesNeeded,typeMismatch.rolesNeeded,typeMismatch.java.util.List,typeMismatch];
    arguments
    [org.springframework.context.support.DefaultMessageSourceResolvable:
    codes [project.rolesNeeded,rolesNeeded]; arguments []; default message
    [rolesNeeded]]; default message [Failed to convert property value of
    type 'java.lang.String[]' to required type 'java.util.List' for
    property 'rolesNeeded'; nested exception is
    java.lang.IllegalStateException: Cannot convert value of type
    'java.lang.String' to required type
    'com.imprender.instateam.model.Role' for property 'rolesNeeded[0]': no
    matching editors or conversion strategy found]</p>
  </blockquote>
  
  <p>Basically, as far as I understood, the checkbox input returns a String[], but my object needs a list, so the binding cannot be perfomed.</p>
  
  <p><strong>How could I bind the array in the list?</strong> (do you have an example?)</p>
  
  <p>Thank you.</p>