title: How to implement correct data binding in controller?
body: <p>I have a jsp page which combines User object using forms. On the last form I'm trying to get <code>Collection&lt;Permission&gt;</code>. But when I'm trying to pass data to controller I'm getting 400 Error because of:</p>
  
  <pre><code>Field error in object 'user' on field 'permissions':
  rejected value [add,view];
  codes [typeMismatch.user.permissions,typeMismatch.permissions,typeMismatch.java.util.Collection,typeMismatch];
  arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.permissions,permissions];
  arguments [];
  default message [permissions]];
  default message [Failed to convert property value of type 'java.lang.String[]' to required type 'java.util.Collection' for property 'permissions'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [it.marco.javaproject.domain.Permission] for property 'permissions[0]': no matching editors or conversion strategy found]
  </code></pre>
  
  <p>Here is my jsp form: </p>
  
  <pre><code>&lt;form:form action="/user/permission" method="POST" modelAttribute="user"&gt;
     &lt;form:checkboxes path="permissions" items="${permissions}" delimiter=&lt;br&gt;"/&gt;
     &lt;form:hidden path="email"/&gt;
     &lt;form:hidden path="password"/&gt;
     &lt;form:hidden path="name"/&gt;
     &lt;input type="submit" value="Next" name="next"/&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>Part of controller:</p>
  
  <pre><code>public String processRoleForm(@ModelAttribute("user") User user, ModelMap model) {
      model.addAttribute("permissions", userService.getPermissions());
      return "user/form/permissionForm";
  }
  </code></pre>
  
  <p>Permission class:</p>
  
  <pre><code>@Entity
  @Table(name = "permission")
  public class Permission implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer id;
  
      @Column(name = "name")
      private String name;
  </code></pre>
  
  <p>If I'm not mistaken I need to use some kind of data binder in my controller. How to implement it? How to properly translate String[] to Collection of Permission?</p>