Skip to Content
처음부터 제대로 배우는 스프링 부트
book

처음부터 제대로 배우는 스프링 부트

by 마크 헤클러, 오시영, 서정대
May 2023
Beginner to intermediate
384 pages
8h 42m
Korean
Hanbit Media, Inc.
Content preview from 처음부터 제대로 배우는 스프링 부트
58
처음부터 제대로 배우는 스프링 부트
@GetMapping("/coffees/{id}")
Optional<Coffee> getCoffeeById(@PathVariable String id) {
for (Coffee c: coffees) {
if (c.getId().equals(id)) {
return Optional.of(c);
}
}
return Optional.empty();
}
3.4.2
POST
로 생성하기
HTTP POST
메서드를 사용해 리소스를 생성합니다.
NOTE
_
POST
는 리소스의 세부 정보(일반적으로
JSON
형식)를 제공합니다. 해당 서비스에
POST
요청을
해서 지정된
URI
에 리소스를 생성합니다.
다음 코드에서 볼 수 있듯,
POST
는 비교적 간단히 구현할 수 있습니다. 스프링 부트의 자동 마
샬링 덕분에 해당 커피 정보를
Coffee
객체로 받습니다. 그리고 해당 객체를 커피 목록에 추가
합니다.
Coffee
객체는 스프링 부트에 의해 언마샬링 (기본값은
JSON
)되어 요청한 애플리케
이션이나 서비스로 반환됩니다.
@PostMapping("/coffees")
Coffee postCoffee(@RequestBody Coffee coffee) {
coffees.add(coffee);
return coffee;
}
3.4.3
PUT
으로 업데이트하기 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

프로그래머의 길 멘토에게 묻다

프로그래머의 길 멘토에게 묻다

David Hoover, Adewale Oshineye, Kang Jung Bin
SRE를 위한 시스템 설계와 구축

SRE를 위한 시스템 설계와 구축

헤더 애드킨스, 벳시 바이어, 폴 블랭킨십, 피오트르 레반도프스키, 애나 오프레아, 애덤 스터블필드

Publisher Resources

ISBN: 9791169210966