which works fine for all exeptions occuring under core url.
I have
Code:@Controller(value="core/*") public class CoreController { public static String exceptionOccurredView = "/core/exceptionOccurred"; @ExceptionHandler(Throwable.class) public ModelAndView exceptionOccurred(Throwable exception, HttpServletResponse response, HttpServletRequest request) { ModelAndView mv = new ModelAndView(); mv.setViewName ( exceptionOccurredView ); mv.addObject ( "requestedUrl", Core.getCurrentUrlWithParams() ); mv.addObject ( "exception", exception ); System.out.println( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + Core.getCurrentUrlWithParams() ); return mv; } @RequestMapping public void test0(HttpServletResponse response, HttpServletRequest request) throws IOException { throw new IOException(); } }
if I go to url
localhost:8080/core/test0
the error page is shown. Also if I go to:
localhost:8080/core/actionDoesNotExist
but if I use:
localhost:8080/controllerDoesNotExist/test0
The error does not get shown, since the annotation @ExceptionHandler is valid only per controller.
So how can you achieve a global, non-controller attached exception/error handler ?


Reply With Quote
