예외 타입에 따라 스프링 MVC와 연동된 뷰를 이용해서 에러 페이지 출력
@ExceptionHandler
어노테이션을 이용SimpleMappingExceptionResolver
클래스 이용@ExceptionHandler
어노테이션@ExceptionHandler(value = {ArithmeticException.class} )
public ModelAndView error(Exception e) {
return ..
}
현재 컨트롤러 실행시 발생하는 예외처리
SimpleMappingExceptionResolver
클래스<beans:bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
👇@Component 변경 하고 싶을 때
@Component
class SimpleMappingExceptionResolver{
}
👇Spring 내부에 있는 클래스를 JavaBase로 생성 하고 싶을 때
@Configuration
class AppConfig{
@Bean //method 위에 선언
pubic SimpleMappingExceptionResolver aa(){
return new SimpleMappingExceptionResolver();
}
}