title: How to bind a List using @ModelAttribute to controller from a JSP form
body: <p>I am trying to get a list of selected candidates to my controller using @modelAttribute with their respective id and blurb. I am able to bring one Candidate correctly but i don't know how to bring a list of candidates thru... I tried to add List&lt;> as i have shown below, but i get </p>
  
  <blockquote>
    <p>ERROR - 
    SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/panel-requests] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class is an interface] with root cause
    org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class is an interface</p>
  </blockquote>
  
  <p>JSP - </p>
  
  <pre><code>&lt;form:form modelAttribute="candidateAddAttribute" 
    action="/panel-requests/requests/${panelRequestForId.id}/empl" method="post"&gt;
  &lt;c:forEach items="${candidates}" var="candidates"&gt;
      &lt;select name="employee" id="employee" disabled="disabled"&gt;
          &lt;option value="default" selected="selected"&gt;${candidates.candidateName}&lt;/option&gt;
      &lt;/select&gt;
      &lt;textarea rows="3" cols="40" id="candidateBlurb" name="candidateBlurb" 
        disabled="disabled"&gt;${candidates.candidateBlurb}&lt;/textarea&gt;
  
      &lt;textarea rows="2" cols="20" id="candidateCV" name="candidateCV"                                
        disabled="disabled"&gt;${candidates.candidateCV}&lt;/textarea&gt;
  &lt;/c:forEach&gt;
  &lt;div id="candidateDiv" id="candidateDiv"&gt;
      &lt;select name="employee" id="employee"&gt;
          &lt;option value="default" selected="selected"&gt;Select Employee&lt;/option&gt;
          &lt;c:forEach items="${employees}" var="employee"&gt;
              &lt;option value="${employee.id}" id="${employee.id}"&gt;
                  ${employee.employeeName}- ${employee.employeeCV}&lt;
              /option&gt;
          &lt;/c:forEach&gt;
      &lt;/select&gt;   
      &lt;textarea rows="3" cols="40" id="candidateBlurb"                
        name="candidateBlurb"&gt;BLURB&lt;/textarea&gt;
      &lt;div id="employeeCv"&gt;&lt;/div&gt;
      &lt;input type="submit" value="Add Candidate" /&gt;
  &lt;/div&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>The above form at first displays list of employee and when user selects employee, enters blurb and hits add candidate button, i take data to controller.  </p>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping(value = "{id}/empl", method = RequestMethod.POST)
  public String getEmployeeDetails(
      @ModelAttribute("candidateAddAttribute") @Valid List&lt;Candidate&gt; candidates,
      BindingResult result, @PathVariable("id") int requestId, Model model) {
  
          //implementation goes here
  }
  </code></pre>
  
  <p>How do I implement List in this case? Thanks in advance.</p>
  
  <p><strong>EDITED PART</strong>
  I tried sending 2 candidate's details, firebug sends it correctly like - 
  Parameters
  candidateBlurb  BLURB sar
  candidateBlurb  BLURB dann
  employee    1
  employee    2</p>
  
  <p>so it can be a problem in initBinder that i ma using, 
  binder.registerCustomEditor(Employee.class,
                  new PropertyEditorSupport() {
                      public String getAsText() {
                          return Long.toString(((Employee) getValue()).getId());
                      }</p>
  
  <pre><code>                public void setAsText(final String text) {
                      Employee employee = Employee.findById(Integer
                              .parseInt(text));
                      setValue(employee);
                  }
              });
  </code></pre>
  
  <p>which only takes 1 employee detail at a time. Is that a problem here???</p>