Jun 6th, 2012, 04:23 PM
Spring MVC: Exception handler sending user back to page that generated the submit.
Here is my scenario:
- User opens the form page,
- User fills up the form and press the submit button,
- If the form data is OK the success page is showed,
- If something is NOT OK, throws a business exception and user gets the form page with a message explaining the error.
Does spring web MVC has something that could help me doing that ?
I could not find anything that helped.
Do you guys know any trick that could help to code that easily?
I have some ideas like putting on the form pages a hidden field with a tag that stores the page url that is making the form, than in exception handler resolver I could get this value from the request object and redirect the user to the page that generated the submit. But it does not “look good” to me.
Any other ideas?
Jun 7th, 2012, 01:19 AM
What you describe here is validation and validation is perfectly handled by spring, instead of hacking around with exception resolvers simply implement a validator (or use JSR-303 for validation) and have spring handle that for you. I suggest a read of the validation chapter/section in the reference guide.
Jun 11th, 2012, 08:47 AM