작콩큰콩
ResponseEntity 사용 이유? / ResponseEntity.ok(list); 본문
응답을 받아서 넘겨줄 때 값만 넘겨주는 것이 아니라 상태코드, 응답 메세지를 함께 리턴해주고 싶을 때 사용한다.
@ResponseBody
@GetMapping("getItems")
public ResponseEntity<List<App001Dto>> getItems(App001Dto params) {
List<App001Dto> list = app001Service.getItems(params);
return ResponseEntity.ok(list);
}
ResponseEntity.ok(list); 의 내용
이렇게 안에 리스트 뿐만 아니라 상태코드와 메세지도 함께 넣어 리턴해줄 수 있다.
<200 OK OK
,[App001Dto
(recid=24, rowIndex=1, seq=24
, uuid=D34CAAA4BAE6F373E05011AC0200290F, description=내용-ABC
, isChecked=0, quantity=55, currUserId=null)
, App001Dto(
recid=23, rowIndex=2, seq=23, uuid=D34CAAA4BAE5F373E05011AC0200290F
, description=null, isChecked=0, quantity=null, currUserId=null)
, App001Dto(
recid=22, rowIndex=3, seq=22, uuid=D3412CA821DC3A7BE05011AC020058D7,
description=null, isChecked=0, quantity=null, currUserId=null)
, App001Dto(
recid=21, rowIndex=4, seq=21, uuid=D33EB49BDB5582EEE05011AC02002B4F
, description=d, isChecked=0, quantity=1, currUserId=null)
, App001Dto(
recid=20, rowIndex=5, seq=20, uuid=D29DDB01DA5218B6E05011AC02005926,
description=금일내용, isChecked=0, quantity=5, currUserId=null)
, App001Dto(
recid=4, rowIndex=6, seq=4, uuid=CFB5B51D8D6691ACE05011AC02000C45
, description=hello, isChecked=1, quantity=30, currUserId=null)
, App001Dto(
recid=2, rowIndex=7, seq=2, uuid=CEFD2DF111E15F92E05011AC0200622B
, description=내용설명2, isChecked=1, quantity=22100, currUserId=null)
, App001Dto(
recid=1, rowIndex=8, seq=1, uuid=CEE7825BFCA8712EE05011AC0200676A
, description=내용설명 edit, isChecked=1, quantity=60, currUserId=null)
],[]>
'작은 콩 개발자 > JAVA' 카테고리의 다른 글
boolean 을 사용하는 간결한 방법 (0) | 2023.06.02 |
---|---|
자바 생성자 (0) | 2023.02.15 |
[주석] @Transactional (0) | 2022.01.06 |
[주석] @RequestBody, @ResponseBody (0) | 2022.01.05 |
Scanner (0) | 2021.05.29 |
Comments