Hi,
I'm new to using the springframework mvc for web development. I'm working with Spring 2.5 and have to put together what I thought was a simple use case.
From one webpage the end-user will enter an account number. After querying the database the results will be shown on another web page. I extended the SimpleFormController and overrode the onSubmit method to retrieve the account number from the command object and query the database. After getting the data I'd like to then show the results on a second page. I returned a modelandview object attaching the queried data in the model return new ModelAndView(new RedirectView(getSuccessView()),model);
Part of the problem is the redirect doesn't seem to work. The second controller is never executed.
From the second webpage the end-user can either re-query using the same account number or enter another account number again showing the results on the second page. Being new to the springframework I'm not sure if I'm looking at doing two simpleformcontroller or a multi-action controller. Any help would be appreciated. I tried using two simpleform controllers where the successview specified in the first controller would be a redirect to the second simpleform controller. the second controller never is executed.
here's my dispatcher-servlet.xml file
<--simpleformcontroller one-->
<bean id="employeeSearchController" class="mypackage.controllers.EmployeeSearchControl ler">
<property name="sessionForm" value="true"/>
<property name="commandName" value="employeeSearch"/>
<property name="commandClass" value="com.dataanalytics.finance.domain.EmployeeSe arch"/>
<property name="validator">
<bean class="mypackage.controllers.validators.EmployeeSe archValidator"/>
</property>
<property name="formView" value="employeesearch"/>
<property name="successView" value="reassignEmployee.htm"/>
<property name="employeeService" ref="employeeService"/>
</bean>
</property>
<property name="formView" value="employeeSearch"/>
<property name="successView" value="redirect:reassigned.htm"/>
<property name="employeeService" ref="employeeService"/>
</bean>
<--second simpleform controller-->
<bean id="reassignedController" class="mypackage.controllers.ReassignedController" >
<property name="sessionForm" value="true"/>
<property name="commandName" value="employeeSearch"/>
<property name="commandClass" value="mypackage.domain.EmployeeSearch"/>
<property name="validator">
<bean class="mypackage.controllers.validators.EmployeeSe archValidator"/>
</property>
<property name="formView" value="employeesearch"/>
<property name="successView" value="reassignEmployee.htm"/>
<property name="employeeService" ref="employeeService"/>
</bean>
<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
<property name="order" value="0"/>
<property name="mappings">
<props>
<prop key="/employeeSearch.htm">employeeSearchController</prop>
<prop key="/reassignEmployee.htm">reassignedController</prop>
</props>
</property>
</bean>


Reply With Quote