This should be a common problem with a solution but I haven't managed to find it anywhere.
I am defining a global exception handler using @ControllerAdvice, I define a new ModelAndView and redirect to my error page. Works great EXCEPT for the fact that now we want to add a link to go back to the original page which of course could vary depending on where the error originated.
What I want to do is to store some kind of context information about the controller that generated the error, for instance if it's MyController then I can access a value via MyController.EXCEPTION_REDIRECT_URL and generate the appropriate link.
I find a lack of context information in the Exception handler rather limiting.