고객사 마다 다른 오류를 주고 싶을 때도 있다. 사실 api의 경우 오류가 터지면 이게 400이든 500이든 무조건 500으로 발생시켜 오류를 반환해준다. 오류 상태를 바꾸고 싶다면 HandlerExceptionResolver를 이용해준다. package hello.exception.resolver; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.web.servlet.HandlerExceptionResolver; import org.springframework.web.se..
api 요청이 실패할 경우에는 html 으로 실패값이 와서는 안된다. 일반 예외와 같이 boot는 BasicError 컨트롤러를 이용해서 api 실패 예외처리도 해준다. Request문서의 Accept가 application/json일 경우 (html이 아닐 경우 아래의 메소드로 작동한다.) 1. html 일경우 2. 그 외 @RequestMapping(produces = MediaType.TEXT_HTML_VALUE) public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { HttpStatus status = getStatus(request); Map model = Collections .unmodi..
- Total
- Today
- Yesterday
- HTTP
- 향해99
- JPA
- reject
- exception
- 백엔드 개발자 공부
- 항해99
- 스프링공부
- ArgumentResolver
- BindingResult
- 항해플러스
- Intercepter
- 스프링부트
- 향해플러스백엔드
- thymleaf
- hypertexttransferprotocol
- SpringBoot
- 백엔드 개발자 역량
- 인터셉터
- rejectValue
- react실행
- 예외처리
- React
- 리터럴
- jpa api
- 향해플러스
- 로그인
- Java
- filter
- 컨트
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |