SPRING
예외처리 어노테이션
나이많은 초보
2022. 10. 7. 17:16
// Controller 어노테이션이 있는 클래스에 한해서 예외 처리를 진행해주는 어노테이션
@ExceptionHandler({NullPointerException.class, NumberFormatException.class})
public String errorHandler() {
return "redirect:/home.kh";
}
그래서 뭐 service나 store 클래스에서 안됨.....
try~catch를 대행하는 내용...
@ExceptionHandler 뒤에 예외처리되는 클래스 내용을 쓰면됩.
// Controller 어노테이션이 있는 클래스에 한해서 예외 처리를 진행해주는 어노테이션
@ExceptionHandler({NullPointerException.class, NumberFormatException.class, SQLException.class})
public String errorHandler() {
return "redirect:/home.kh";
}