「Spring MVC」@ExceptionHandlerで例外ハンドラの実装サンプル

2017年9月26日

Javaコード
@ExceptionHandler
public ModelAndView exceptionHandler(Exception ex){
ModelAndView mv = new ModelAndView(“error");
mv.addObject(“exception", ex);
System.out.println(“in testExceptionHandler");
return mv;
}

@RequestMapping(“/error")
public String error(){
int i = 5/0;
return “hello";
}

Java

Posted by arkgame