티스토리 뷰
Spring - @ExceptionHandler
-
특정예외가 발생한 요청을 처리하고 싶은경우 사용한다.
-
@ExceptionHandler
- Spring 3.0 부터 지원
- RESTAPI의 경우 응답본문에 에러에 대한 정보를 담아주고, 상태코드를 설정하려면 ResponseEntity를 주로 사용한다.
- @ModelAttribute를 지원하지 않는다.
- 가장 구체적인 Exception을 Handling 하는 ExceptionHandler가 처리한다.
- [https://docs.spring.io/spring/docs/5.1.8.RELEASE/spring-framework-reference/web.html#mvc-ann-exceptionhandler]
Web on Servlet Stack
Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning. The formal name, “Spring Web MVC,” comes from the name of its source module (spring-webmvc), but it is more commonl
docs.spring.io
- 여러 Exception을 처리하고 싶은경우
- 이 경우에는 두가지 타입을 모두 받을수 있는 Exception을 Argument로 정의해야한다.
'Spring' 카테고리의 다른 글
Spring - HATEOAS (0) | 2019.08.12 |
---|---|
Spring - MVC @ControllerAdvice (0) | 2019.08.01 |
Spring - MVC @InitBinder (0) | 2019.08.01 |
Spring - MVC @ModelAttribute의 다른사용방법 (0) | 2019.08.01 |
Spring - MVC @ResponseBody_ResponseEntity (0) | 2019.07.31 |
댓글