
@RestControllerAdvice + @ExceptionHandler 란? Spring에서 예외 처리를 할 때 Global 영역에서 관리해 주는 기능으로 @ControllerAdvice, @RestControllerAdvice를 사용합니다. 먼저 각 어노테이션 별로 간단하게 짚고 넘어가겠습니다. @ControllerAdvice vs @RestControllerAdvice ControllerAdvice 어노테이션을 살펴보면, 대상을 지정하지 않은 모든 컨트롤러에 @ExceptionHandler와 @InitBinder의 기능을 적용해 준다고 합니다. // 패키지 하위 모두 적용 @ControllerAdvice("org.bot.controllers") public class Advice1{} // 특정 ..

서블릿 API 예외 처리 package hello.exception.sevlet; import org.springframework.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.ErrorPage; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; @Component public class WebServerCustomizer implements WebSer..