I have a form with a checkbox input:
<form:input id="garder_${indice}" path="mesFormulaires[${indice}].garder"
type="text" name="garder_${indice}" />
I want to get if the checkbox is checked or not in Java. How is it possible, using getter/setter with a boolean named “garder”. I hope it’s possible with Java methods, but I don’t know them.
If you are using Spring MVC I suggest you to use the
form:checkboxtag and bind it to a property of themodelAttributeobject of your form.Then in your page:
Be sure to set as
modelAttributeof your form an instance ofYourModelAttribute.