๋ฐ์ํ
โป ์ด์ ํธ
@GetMapping
- QuickController์ get๋ฉ์๋๋ฅผ ๋๊ฐ ์ถ๊ฐํ๋ค.
- @RequestParam : ์ผ๋ฐ์ ์ธ ๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ๋ ์ฌ์ฉํฉ๋๋ค.


- @PathVariable
: Path๋ก ๊ฐ์ ๋ฐ์ ์ ์๋ค.

company๋ค์ ์ ๋ ฅ๊ฐ์ ์ฃผ์๋ก ์จ ๊ฒ์ด ํ์ธ๋๋ค.
- @RequestParam : ์ผ๋ฐ์ ์ธ ๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ๋ ์ฌ์ฉํฉ๋๋ค.
@PostMapping
- Post ๋ฉ์๋๋ Body๋ฅผ ๋ฐํํ๊ธฐ ๋๋ฌธ์ ๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ๋ @RequestBody ๋ฅผ ์ฌ์ฉํ๋ค.

- ์ค์จ๊ฑฐ์์ ์คํ.

- URL ์ ์ฟผ๋ฆฌ์คํธ๋ง์ด ๋์ mapping๋ช
์ด ์ ํ ์๋ค.
- -d : body๋์ด๋ค.
์ด๊ณณ์ ์ ๋ ฅํ ๊ฐ์ด ๋ด๊ธด ๊ฑธ ํ์ธํ ์ ์๋ค.
jsonํ์ ์ฌ์ฉํ๊ธฐ
→ Dto(๋๋ domain)์ ๋ง๋ค์ด ๋ฐ์ดํฐ๋ฅผ ์ฃผ๊ณ ๋ฐ๋๋ค.
- ์ปจํธ๋กค๋ฌ์ Post๋ฉ์๋๋ฅผ ๋ง๋๋๋ฐ ์ธ์/๋งค๊ฐ๋ณ์ ํ์
์ DTO ํด๋์ค๋ก ์ ์ธํ๋ค.

- dto ํจํค์ง์ ๋งค๊ฐ๋ณ์์ฉ ItemDto ํด๋์ค์ ๋ฐํ๋ฐ์ดํฐ์ฉ ReponseDto ํด๋์ค ์ฝ๋.

- ์ค์จ๊ฑฐ์์ ์คํํด๋ณด๋ฉด jsonํ์
์ผ๋ก ๋ฐ์ดํฐ๊ฐ ์ฃผ๊ณ ๋ฐ๋ ๊ฒ ํ์ธ๋๋ค.

๋ฐ์ํ
'๐ Spring > ๐ Spring Boot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [SpringBoot]์คํ๋ง์ผ๋ก ์ ํ (1) | 2025.02.20 |
|---|---|
| [SpringBoot][Maven][RestAPI]MyBatis, JPA์ฌ์ฉํ๊ธฐ (0) | 2025.01.27 |
| [SpringBoot][Maven][RestAPI]ํ๊ฒฝ์ค์ (์์กด์ฑ ์ถ๊ฐ-web, swagger, lombok) (0) | 2025.01.26 |
| [Spring]์์ ์๋ฐ ๊ฐ๋ฐ-ํ์ ๋๋ฉ์ธ ๊ฐ๋ฐ๊ณผ ํ ์คํธ (0) | 2025.01.17 |
| [SpringBoot]AOP ์ ๋ฌธ-์ค๋ช ๊ณผ ์ฌ์ฉ๋ฒ (0) | 2025.01.10 |