웹개발 (자바, 스프링, React)/웹개발
Exception class의 ResponseStatus 사용
아이셩짱셩
2021. 1. 14. 10:45
728x90
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
With {@code HttpServletResponse.sendError}, the response is considered
complete and should not be written to any further. Furthermore, the Servlet
container will typically write an HTML error page therefore making the
use of a {@code reason} unsuitable for REST APIs. For such cases it is
preferable to use a {@link org.springframework.http.ResponseEntity} as
a return type and avoid the use of {@code @ResponseStatus} altogether.
728x90