Exception 페이지 설정

package com.junho.blog.handler;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
@ControllerAdvice
@RestController
public class GlobalExceptionHandler {
@ExceptionHandler(value=Exception.class)
public String handleArgumentException(Exception e) {
return "<h1>"+e.getMessage()+"</h1>";
}
}
새로운 패키지를 만들고 Exception 처리를 하는 클래스를 생성해줍니다.
@ControllerAdvice : 는 모든 컨트롤러의 정보를 받아올 수 있는 어노테이션입니다.
@ExceptionHandler : value에 해당하는 에러에 대한 값을 처리를 할 수 있게 만들어주는 어노테이션입니다.
