title: Spring Mvc submit/delete checked (selected) records from table
body: <p>I'm trying to submit selected items from a table and moake some modifications on them but I couldn't get it work.</p>
  
  <p>MyObject.java</p>
  
  <pre><code>public class MyObject{
      boolean checkControl = true; //default true
      private String name;
      private String code; 
  
      //getters &amp; setters
  }
  </code></pre>
  
  <p>MyObjectForm.java</p>
  
  <pre><code>public class MyObjectForm {
      private List&lt;MyObject&gt; myList;
  
      public List&lt;MyObject&gt; getMyList() {
          return myList;
      }
  
      public void setMyList(List&lt;MyObject&gt; myList) {
          this.myList= myList;
      }
  }
  </code></pre>
  
  <p>list-myObjects.jsp</p>
  
  <pre><code>&lt;form:form action="submitList" method="post" modelAttribute="myObjectForm"&gt;
      &lt;table&gt;
          &lt;tbody&gt;
              &lt;c:forEach items="${myObjectForm.myList}" var="row" varStatus="status"&gt;
          &lt;tr&gt;
                  &lt;td&gt;
                      &lt;spring:bind path="myList[${status.index}].checkControl"&gt;
                      &lt;input type="checkbox" value="&lt;c:out value="${status.value}"/&gt;" name="isChecked" &lt;c:if test="${row.checkControl}"&gt; checked="checked" &lt;/c:if&gt; /&gt;
                      &lt;/spring:bind&gt;
                      &lt;/td&gt;
                      &lt;td&gt;${row.name}&lt;/td&gt;
                      &lt;td&gt;${row.code}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/c:forEach&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;  
      &lt;button type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>And the controller</p>
  
  <pre><code>@RequestMapping(value = "/submitList", method = RequestMethod.POST)
  public String save(@ModelAttribute("myObjectForm") MyObjectForm myObjectForm, Model model) {
  
      List&lt;MyObject&gt; selectedtList = myObjectForm.getMyList(); //returns null
  
      if (selectedtList == null) {
          System.out.println("no objects selected");
      }
      else {
          //Make some computation
      }
      model.addAttribute("resultArray", selectedtList);
  
      return "display-items";
  }
  </code></pre>