문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:mvc:handlerexceptionresolver [2014/10/31 17:38] kwon37xi |
springframework:mvc:handlerexceptionresolver [2018/02/14 08:32] kwon37xi |
||
---|---|---|---|
줄 35: | 줄 35: | ||
andView.setViewName(" | andView.setViewName(" | ||
return andView; | return andView; | ||
+ | } | ||
+ | // JSON 에러 내면서 Http Status Code 변경 | ||
+ | @ExceptionHandler(Exception.class) | ||
+ | @ResponseBody | ||
+ | public ResponseEntity< | ||
+ | // org.springframework.http.HttpStatus 를 참조할 것. | ||
+ | HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; | ||
+ | SomeErrorObject errorObject = new SomeErrorObject(); | ||
+ | |||
+ | return new ResponseEntity<> | ||
} | } | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== 주요 Spring MVC Exception에 대해 오버라이드 하지 말 것 ===== | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | * 주요 Exception들에 대해 올바른 응답 코드가 내려가도록 처리한다. | ||
+ | * [[https:// | ||
+ | |||
+ | ===== 참조 ===== | ||
+ | * [[http:// | ||
+ |