I am pretty new to Spring and would appreciate any help on the following problem:
I have pageA.jsp with html formA, which submits to ControllerA and uses ModelA. The success view for pageA.jsp is pageB.jsp. pageB.jsp has 2 forms, each of which have their own Model and Controller. The first form in pageB.jsp is identical to formA and it submits to ControllerA and uses ModelA. The second form, formB, submits to ControllerB and uses ModelB.
In formA several html fields are populated by values in ModelA. For example, in pageA.jsp:
Where “command” refers to ModelA and findWithin is a Boolean.
The problem is that when pageA.jsp loads it tries to retrieve values from ModelB so I get an error like:
“…Unable to find a value for "findWithin" in object of class ModelB”
In pageB.jsp if I comment out
” in the first form (formA) I get the same error, but it refers to the next line that tries to get a value from ModelA (i.e.
Here is a section of my servlet.xml (the views are mapped to their corresponding .jsps):
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<bean id=" pageAForm " class=" web. pageAForm ">
<property name="formView" value="pageAView"/>
<property name="successView" value="pageBView"/>
<bean id="pageBForm" class=" web.pageBForm">
<property name="formView" value=" pageBView "/>
<property name="successView" value="pageCView"/>
My questions are:
When I load pageA.jsp, why is it looking in ModelB for values on pageB.jsp, which hasn’t even loaded yet?
Do I have to approach this differently in order to have 2 forms on one page that each use their own model and controller?