Wednesday, May 13, 2009

Return ModelAndView in Spring mvc onSubmit()

You need to return ModelAndView In Spring's SimpleFormController onSubmit() method. There are a few options here.

1. Redirect to another page
return new ModelAndView(new RedirectView("anotherPage.htm");

2. Return to the same form
return new ModelAndView(getSuccessView());

As long as you return "new" ModelAndView, you will have to go through formBackingObject() method.

3. Return to the same form but bypass formBackingObject() method
return showForm(request, errors, getSuccessView());
showForm() method calls and carries all reference data.


No comments:

Post a Comment