jeudi 14 janvier 2021

Get checkbox values as array from HTML form in spring

I have a form that displays all the items in my list. There is a checkbox next to each element:

<input type="checkbox" name="selected" value="${product.id}">

After I click the Continue button, I get into a controller where I want to have a list of all the checkboxes selected. I tried to do it like this:

@GetMapping
    public String getOrderForm(Model model, @RequestParam(value = "selected") String[] selected){

But I am getting the error that there is no such object. How can I get this checkbox list?




Aucun commentaire:

Enregistrer un commentaire