2

I have configured the SimpleMappingExceptionResolver in my web application, which is handling all the unexpected exceptions in the application and directing the user a to simple error page for recovery.

But what would be a best practice of handling an expected exception (more specifically: exception caused by hibernate optimistic concurrency control)?

I don't want the user to be directed to a new error page, but allow him/her to continue working in the same jsp page. What is the best method to achieve this?

1
  • swallow the exception where they can occur (maybe log and give a warning on the same jsp page) ? Commented Jul 21, 2010 at 20:10

1 Answer 1

1

Assuming Spring 3, you can annotate methods on your Controller class with @ExceptionHandler to define what should happen when particular types of exceptions come out of your handler methods. The signature is not quite as flexible as @RequestMapping methods, but you can generally manage what you want. (Which in this case sounds like just add an error message to the model map and re-run the method that handles GET)

Sign up to request clarification or add additional context in comments.

1 Comment

Just be mindful that you don't have an implicit map, if you have methods annotated with @ModelAttribute that you're using to populate it, you may need to manually rerun them depending on the View!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.