I am working with Spring MVC 2.5.
Oftentimes, I am only using one form in all my JSP. Now I need to add another form into the same JSP.
My question is, will Spring MVC still support the same lifecycle method whichever form I submit?
I mean, the same databinding, validation, errorhandling, form controller etc?
<div>
<form:form method="post" commandName="station">
</form>
</div>
<div>
<form:form method="post" commandName="fields">
</form>
</div>
The old-style controllers you’re using can only support one command object, and therefore only one form, at a time. @Arthur’s answer shows that you can’t really put both forms on one page, because any given controller will only supply one form object, you’ll never get both active at once.
If you want to do this, you’re going to have to stop using the old-style controllers (which are obsolescent in Spring 2.5, and deprecated in Spring 3), and use annotated controllers, which are much more flexible. You can mix up your forms pretty much as complex you want.