Dec 18th, 2012, 04:56 AM
ExceptionResolver: display error in current page
I wonder if it is possible to write an ExceptionResolver that allows me to set an error message (or any kind of data) on the request and forward the user back to the page he was coming from. All the filled in fields should also be set again.
I'm using the @MVC model with spring 3.1.x. This should work in a similar way like when you validate a form's input fields using a Spring Validator. In the latter, an Errors or BindingResult is populated with the result of the validation.
I just don't want to write this boilerplate code in each of my controllers. It should be managed on a central place.
Dec 18th, 2012, 06:17 AM
No... The ExceptionResolver is to generic for this it isn't aware of the context. It might not even be possible to render a page as the constructing the model might have failed and what would you then render?
If you want this to be part of your flow then you need to add it to your controller I'm afraid and handle it there.
Dec 18th, 2012, 06:26 AM
What we want to achieve is to display an error message in case of a specifc error message. This should be shown on the page where the user is coming from. If all the filled in fields could be preserved, that would have been nice. I wanted to implement this in a generic way so that we wouldn't have to copy this logic in all of the controllers.