I have Form with CheckBoxes on my index.html.
<form name="formCheckBox" id="formCheckBox" action="/filter" method="POST">
<div>
<input type="checkbox" id="onechange" name="onechange" onclick="this.form.submit();">
<label for="onechange">one change</label>
</div>
<div>
<input type="checkbox" id="nochanges" name="nochanges" onclick="this.form.submit();">
<label for="nochanges">no changes</label>
</div>
</form>
I'm trying to read values of both Checkboxes (on or off) in Controller after clicking on any Checkbox (need a page update). And feels like It does not go to Controller at all. So, how to read it in Controller and How to send those values back on my new page filter.html?
Controller:
@PostMapping("/filter")
public String checkBoxAction (@RequestParam("onechange") String onechange,
@RequestParam("nochange") String nochange){
System.out.println(onechange);
System.out.println(nochange);
return ("/filter");
}
Aucun commentaire:
Enregistrer un commentaire