Hyerin's Logs

  • 홈
  • 태그
  • 방명록

API 2

[Spring Boot] 일관적인 API 응답 RestResult, RestError

목차개요HttpStatus 간략 설명RestResult, RestError 코드컨트롤러 구현개요Spring Boot에서 클라이언트에게 어떻게 일관적인 응답을 줄 것인가?Spring Boot로 개발을 했던 사람이라면 INTERNAL_SERVER_ERROR 라는 에러를 만나봤을 것이다.BAD_REQUSET 인 경우에도 개발자가 예외처리를 하지 않으면 INTERNAL_SERVER_ERROR 로 나오기도 한다.HttpStatus 간략 설명HttpStatus 코드는 성공과 실패 케이스로 나뉜다.자주 볼 수 있는 실패 케이스는 다음과 같다.HttpStatusCode설명OK200성공BAD_REQUEST400클라이언트가 요청 인자를 잘못 보냈을 때UNAUTHORIZED401인증 실패FORBIDDEN403인가 실패NOT..

Software Engineering/[BE] Spring Boot (Java) 2024.06.26

[Spring Boot] API 응답에 null 값 포함 안 시키는 어노테이션

@Getter@AllArgsConstructor@NoArgsConstructorpublic class UserDto { @NotNull private Long id; @JsonInclude(JsonInclude.Include.NON_NULL) private String username; @JsonInclude(JsonInclude.Include.NON_NULL) private String email;}@JsonInclude(JsonInclude.Include.NON_NULL) 어노테이션을 사용하면 해당 값이 null일 경우에 json 응답으로 전달하지 않는다.

Software Engineering/[BE] Spring Boot (Java) 2024.06.22
이전
1
다음
더보기
프로필사진

Hyerin's Logs

개발/일상 로그

  • 분류 전체보기 (14)
    • Software Engineering (11)
      • [FE] React.js (0)
      • [BE] Spring Boot (Java) (4)
      • [Infra] Cloud, Server (0)
      • Algorithm (7)
      • Article (0)
    • Daily (3)
      • Log (3)

Tag

Spring Boot, 2024년 회고, jsoninclude, h2gis, API, 버킷리스트, hashing, springboot, queyrl dsl, build.gradle, algorithm, resterror, 일상, 알고리즘, 2025년, prefix, restresult, LeetCode, 해싱, querydsl,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/05   »
일 월 화 수 목 금 토
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

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바