Spring
[TIL] 231228 ResponseEntity<T> ResponseEntity<?> 제네릭 클래스
studymode
2023. 12. 28. 19:34
제네릭
Generic(제네릭)은 클래스 외부에서 사용자에 의해 지정됨 (specific타입의 반대 개념)
제네릭 타입
| 타입 | 설명 |
| <T> | Type |
| <E> | Element |
| <K> | Key |
| <V> | Value |
| <N> | Number |
private ResponseEntity<?>
응답값을 모를때 사용
class ResponseEntity<T>
<T>는 Wrapper클래스를 받을 수 있다
ResponseEntity<T>는 HttpEntity<T>를 상속받는다
HttpEntity는 HTTP요청 혹은 응답에 해당하는 HttpHeader와 HttpBody를 포함하는 클래스이다
ResponseEntity는 HttpStatus,HttpHeader, HttpBody를 포함한다.
CommonResponseDto

Controller단

Service단

CommonResponseDto는 wrapper클래스도 받아올 수 있기 때문에
boardResponseDto(board)가 아닌 그냥 board로 반환할 수 있다