I have an class that contains an Boolean attribute
class A {
Boolean marked;
[here getter and setter]
}
On my jsp page I connect the checkbox to the model attribute:
<form:form method="POST" action="updateA" modelAttribute="myAInstance">
<form:checkbox path="marked"/>Valid<br>
<input type="submit" value="Save"/>
</form:form>
...
<span>From the DB: ${myAInstanceFromDB} </span> // this displayes true
When submitting the Controller
gets the correct value (myAInstance
) and I save it in the DB
. But if I reload the page (myAInstanceFromDB
) the checkbox
I have previously selected and saved is not checked. I guess it's beause the path of the checkbox points to modellattribute
to be post to the server
and not to the database
object I past to the page. How do I mark the checkbox when loading the page?