I have a small Spring MVC project that implements serving and processing functionality. It has a Member class that is used for a form bean. The Member class just has tow
String fields, firstName and lastName. The following is a form to submit a Member for a nomination:
The following
jsp displays a thank you for submitting the nominee:
My NomineeController is :
Here is my config file to define the controllers:
This example is from the book Spring In Practice by Wheeler and White.
When you enter a nominee's first and last name on form.jsp and hit submit, the processFormData() method is called in the NomineeController. When this completes, it returns the string "nominee/thanks" which is resolved to the /WEB-INF/jsp/nominee/thans.jsp page above. The URL is /sip/main/nominee/thanks and displays the first and last name entered on the form.
The book indicates to add redirect-after-post behavior, simply pre-pend the logical view name (thanksViewName) with "redirect:". So I tried to do this. If I change p:thanksViewName="nominee/thanks"/> to p:thanksViewName="redirect:nominee/thanks/>" the URL the browswer goes to is
/main/nominee/nominee/thanks which is incorrect, so I get a 404. If I use p:thanksViewName="redirect:/sip/main/nominee/thanks" the browser is redirected to the correct URL, but the first and last names are both null.
What is the correct way to append "redirect:" on to the logical view name so I get the correct URL and firstname and lastname are those entered on the form?
Thanks Much in advance