title: Getting value of list of checkboxes using thymeleaf, spring boot
body: <p>Here, i have a form which have list of user with checkboxes. I need to get boolean values as well as user ids of respective checkboxes to know the boolean value whether true or false for each user to insert values as per user in the database.
  For Example:</p>
  
  <p><a href="https://i.stack.imgur.com/D0ZmR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0ZmR.jpg" alt="enter image description here"></a></p>
  
  <p>Let's say we have three users of id 1,2,3 then i need the checkbox checked value like 1,0,1 for respective user. So, as to insert boolean value for the user if checked or not. </p>
  
  <p>&lt;-- main.html --></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head lang="en" th:include="fragments/header :: header"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div lang="en" th:include="fragments/navigation :: navigation"&gt;&lt;/div&gt;
  
      &lt;div class="container" id="attendanceDiv"&gt;
          &lt;div class="alert alert-success" role="alert"
              th:if="${error} == 'false'" th:text="${message}"&gt;&lt;/div&gt;
  
          &lt;div class="alert alert-danger" role="alert"
              th:if="${error} == 'true'" th:text="${message}"&gt;&lt;/div&gt;
  
          &lt;h3&gt;Add&lt;/h3&gt;
          &lt;hr&gt;&lt;/hr&gt;
          &lt;form id="attendanceform" class="col-xs-12 col-sm-4" role="form"
              th:action="@{/attendance/createall}" method="post"&gt;
              &lt;div class="checkbox" th:each="users : ${users}"&gt;
                  &lt;label&gt; 
                      &lt;input type="checkbox" id="present" name="present"
                      th:text="${users.firstname} + ' ' + ${users.lastname}"&gt;&lt;/input&gt; 
                      &lt;input type="hidden" id="user" name="user" th:value="${users.id}" /&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;p&gt;
                      &lt;button type="submit" class="btn btn-default"&gt;Save&lt;/button&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
      &lt;div lang="en" th:include="fragments/footer :: footer"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please help me i don't know how to get input data for multiple checkboxes and i am using spring boot, spring data jpa with thymeleaf.</p>