All the examples seemed straight forwards:
Just annotate a method in a controller:
import org.springframe...ExceptionHandler;
import org.springframe...ModelAndView;
import org.springframe...Controller;
....
@Controller
public class MyController {
....
@ExceptionHandler(SomeException.class)
public ModelAndView myExceptionHandler(
SomeException exception){
blah
}
...
}
But it just would never catch my exceptions. Very frustrating.
But in the end a google search to the end of the world where someone mentioned in the comments that the exceptionhandler method have to be be in the same class as the method throwing the exception.
Very odd restriction compared to Spring's usual very agile and generic annotation.
So I added my handlers to my abstract controller class that all my controllers extend and problem solved, with some hair still intact.