title: How to bind input elements to an arraylist element in Spring MVC?
body: <p>How to bind input elements to an arraylist element in Spring MVC?</p>
  
  <p>The view model:</p>
  
  <pre><code>public class AssigneesViewModel {
  
      private int evaluatorId;
      private int evaluatedId;
      private String evaluatorName;
      private String evalueatedName;
      //getters and setters
  }
  </code></pre>
  
  <p>The model attribute:</p>
  
  <pre><code>public class AssignEvaluationForm{
     private ArrayList&lt;AssigneesViewModel&gt; options;
     public ArrayList&lt;AssigneesViewModel&gt; getOptions() {
        return options;
     }
  
     public void setOptions(ArrayList&lt;AssigneesViewModel&gt; options) {
        this.options = options;
     }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>@RequestMapping(value="addAssignment", method = RequestMethod.GET)
  public String addAssignment(Model model){
       model.addAttribute("addAssignment", new AssignEvaluationForm());
       return "addAssignment";
  }
  </code></pre>
  
  <p>Then in the jsp i have 4 hidden inputs which represent the fields for the evaluatedId, evaluatorId, evaluatorName, evaluatedName -> options[0]. 
  How i am going to write the jsp code to map those inputs with an element of the arrayList? </p>
  
  <p>Update:</p>
  
  <pre><code>&lt;form:form commandName="addAssignment" modelAttribute="addAssignment" id="addAssignment" method="POST"&gt;
  //..........
       &lt;c:forEach items="${addAssignment.options}" var="option" varStatus="vs"&gt;
           &lt;div id="assigneesOptions" &gt;    
               &lt;form:input path="addAssignment.options[${vs.index}].evaluatedId" value="1"&gt;&lt;/form:input&gt;
           &lt;/div&gt;
      &lt;/c:forEach&gt;
   //..............
  &lt;/form:form&gt;
  </code></pre>
  
  <p>With this update i get the following error:</p>
  
  <pre><code>java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'options[]' available as request attribute
  </code></pre>