Reputation: 397
I want to have two page views and two controllers.
profile/update.jsp
form:form id="updateform" commandName="profile" method="post" action="/profile/update/${id}"
account/update.jsp
form:form id="updateform" commandName="account" method="post" action="/account/update/${id}"
Now I want to merge them into one page view.
I should add profile and account in profile/update.jsp
, and then submit them with one button.
How can I do that? Please let me know.
Thanks
Upvotes: 1
Views: 2695
Reputation: 33374
One form can handle only one set of data. The best solution is to create a complex bean with two entites:
public class FormData {
private Account account;
private Profile profile;
....
}
have a form:
<spring:url value="/handler" var="handler" />
<spring:form commandName="formData" action="${handler}" method="POST">
<form:input path="account.id" />
<form:input path="profile.name" />
...
</spring:form>
and a controller method:
@RequestMapping("handler")
public update(@ModelAttribute("formData") FormData formData){
...
}
Upvotes: 2