title: How to pass checkbox values to the controller in Spring MVC
body: <p>I have a jsp page with list of functions. Here in controller I get this list from database and pass it to jsp.</p>
  
  <pre><code>@RequestMapping(value = "/functionlist", method = RequestMethod.GET)
      public ModelAndView functionList(Model model) throws Exception {
          ModelAndView mv = new ModelAndView("functionList");
          mv.addObject("functionList", getFunctionsFromDB());
          return mv;
      }
  </code></pre>
  
  <p>In my jsp page I create table using this list of functions</p>
  
  <pre><code>&lt;table id="table"&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Action&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;c:choose&gt;
          &lt;c:when test="${not empty functionList}"&gt;
              &lt;c:forEach var="function" items="${functionList}"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;input name="id" value="${function.id}" hidden&gt;&lt;/td&gt;
                      &lt;td&gt;${function.name}&lt;/td&gt;
                      &lt;td&gt;
                          &lt;input type="checkbox" id="${function.id}" value="${function.action}"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/c:forEach&gt;
          &lt;/c:when&gt;
      &lt;/c:choose&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;button type="submit" name="save"&gt;Save&lt;/button&gt;
  </code></pre>
  
  <p>I also give function id to checkbox id.</p>
  
  <p>My Function entity is the following</p>
  
  <pre><code>public class Function {
  
      private Integer id;
      private String name;
      private Boolean action;
  ...
  }
  </code></pre>
  
  <p>I want to press button Save and get in controller "/functionlist/save" my list of checkbox values.</p>