🏆 2024

맛집 분야 크리에이터

🏆 2023

IT 분야 크리에이터

👩‍❤️‍👨 구독자 수

182

✒️ 게시글 수

0
https://tistory1.daumcdn.net/tistory/4631271/skin/images/blank.png 네이버블로그

🩷 방문자 추이

오늘

어제

전체

🏆 인기글 순위

티스토리 뷰

728x90
반응형

 

https://tistory1.daumcdn.net/tistory/4631271/skin/images/blank.png

 

 

만약 DTO에는 a,b,c,d,e 라는 필드가 추가되어있고

Mapper에서는 select a,b from table 쿼리로 데이터를 가져올 때,

디폴트로 c,d,e는 null값으로 추가되어 출력된다.

이때 c,d,e가 함께 출력되지 않도록 하는 간단한 방법!

 

DTO에 @JsonInclude(JsonInclude.Include.NON_NULL)를 추가해준다.!!!

 


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class YourDTO {
	private String a; 
    private String b; 
    private String c; 
    private String d; 
    private String e;
    ...
}

 

 

반응형

 

728x90
반응형
댓글

돔돔이님의
글이 좋았다면 응원을 보내주세요!