// 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";
	}

'SPRING' 카테고리의 다른 글

LOG4j 등록  (0) 2022.10.11
AOP를 이용한 트랜젝션  (0) 2022.10.11
AOP 심화 : 메소드 실행시간  (0) 2022.10.07
AOP 배우기  (0) 2022.10.07
220916 스프링 게시판_댓글 8-2 댓글리스트출력  (0) 2022.09.16

+ Recent posts