Map checkboxes to List using Sprint Boot and Thymeleaf
<p>I have a <strong>Spring Boot 1.3.0</strong> app that uses <strong>Thymeleaf</strong>. I have a form on a page that allows a user to upload a file. I would like to add some checkboxes also return back to my controller.  </p>

<p>I have not found a good example how to do checkboxes this way.  I think I have to define a list in my model, and let Thymeleaf display all the check boxes, but I have not been able to make it work.</p>

<p>Here is my controller:</p>

<pre><code>@Controller
public class CustomerDataController {

    private static final String SEARCH_TYPES = "searchTypes";

    @RequestMapping(value = "/upload", method = RequestMethod.GET)
    public String displayUpload(Model model) {
        initModel( model );
        return "upload";
    }

    private void initModel(Model model) {
        model.addAttribute( UPLOAD, null );
        // the values to display as check box title &amp; values
        model.addAttribute(SEARCH_TYPES, Arrays.asList("Search A", "Search B"));
        // list to store what the user checks on the UI 
        model.addAttribute("searchValue", new ArrayList&lt;&gt;());
        model.addAttribute( customerResults );
    }

    @Transactional
    @RequestMapping(value = "/userFile", method = RequestMethod.POST)
    public String handleFileUpload(@RequestParam("myFile") MultipartFile file, Model model, Authentication authentication) {

    // looking to get searchValue list, but not sure this is right
    }
}
</code></pre>

<p>And here the important bits of my html:</p>

<pre><code>&lt;form onsubmit="return validate(this)" action="userFile"
      th:action="@{/userFile}" method="post" enctype="multipart/form-data"&gt;
    &lt;input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/&gt;
    &lt;ul&gt;
        &lt;li th:each="search : ${searchTypes}"&gt;
            &lt;input type="checkbox" th:field="*{searchValue}" th:value="${search}"/&gt;
            &lt;label th:text="#{${search}}"&gt;&lt;/label&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;&lt;input type="file" name="myFile" id="myFile"/&gt;&lt;/p&gt;
    &lt;p&gt;&lt;input type="submit" class="btn btn-success" value="Submit Customer Data"/&gt;&lt;/p&gt;
    &lt;input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/&gt;
&lt;/form&gt;
</code></pre>

<p>The list of checkboxes build properly, but when I select any of them, no values show up in the model of my controller.</p>

<p>Can someone please point me in the right direction to return a list of selected checkboxes to my controller?</p>