I’m a bit confused about how an object could be edited with Spring Forms, for instance: suppose I have an object Person who has a lot of attributes because I obtain it from a dao, and I only want to provide the field “street” for editing, I would have this in my PeopleController:
@RequestMapping("editPerson")
public void editPerson (Model model) {
Person person = dao.getThatPerson ();
model.addAttribute (person);
}
And in my view file I would have nothing but this:
<form:form method="post" action="" commandName="person">
<form:input path="street" />
<input type="submit" value="Edit!" />
</form:form>
So when I post the form, will the other attributes of the Person object be preserved? For instance person’s name, surname, username, age, etc. Otherwise, how could this be accomplished?
Store your model object in session, like so: