RequestBody
-
Spring Boot - @PathVariable & @RequestParam & @ModelAttributeFramework & Library/Spring Boot 2023. 2. 6. 13:27
@PathVariable & @RequestParm & @ModelAttribute @PathVariable http://localhost:8080/api/member/17 http://localhost:8080/api/member/25 REST API에서 위와 같이 URI에 변수가 들어가는 것을 본 적 있을 것이다. 위 URI에서 밑줄 친 부분이 @PathVariable 애너테이션으로 처리해 줄 수 있는 부분이다. 이처럼, URI에 파라미터를 포함시킨 요청을 @PathVariable 애너테이션을 사용하여 처리할 수 있다. @RestController public class MemberController { @GetMapping("/member/{id}/{name}") public String findM..
-
Spring Boot - PUT APIFramework & Library/Spring Boot 2022. 2. 1. 18:22
PUT API @PutMapping @PutMapping(value = "/default") public String putMethod() { return "Hello World"; } - PUT API를 제작하기 위해 사용되는 애너테이션이다. - PUT API는 리소스의 업데이트를 위해 사용되는 API이며, 해당 리소스가 존재하면 갱신하고, 리소스가 없을 경우 생성해주는 API이다. - 기본 적인 동작 방식은 POST API와 동일하다. - 컨트롤러와 매핑된 URL로 PUT 요청을 하면, "Hello World"가 응답되는 것을 확인할 수 있다. @RequestBody @PutMapping(value = "/member") public String putMember(@RequestBody Map put..
-
Spring Boot - POST APIFramework & Library/Spring Boot 2022. 2. 1. 14:43
POST API @PostMapping @PostMapping(value = "/default") public String postMethod() { return "Hello World"; } - POST API를 제작하기 위해 사용되는 애너테이션이다. - "@RequestMapping"과 POST method가 결합된 애너테이션이다. - 일반적으로 추가하고자 하는 리소스를 HTTP Body에 담아서 서버에 요청하지만, 그냥 요청을 해도 응답을 받는 모습을 확인할 수 있다. @RequestBody @PostMapping("/member01") public String postMember(@RequestBody Map postData) { StringBuilder sb = new StringBuilder(..