PathVariable
-
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 - GET APIFramework & Library/Spring Boot 2022. 1. 31. 20:21
GET API @RestController - Spring Framework 4 버전부터 사용 가능한 애너테이션이다. - "@Controller"와 "@ResponseBody"가 결합된 애너테이션이다. - 컨트롤러 클래스 하위 메서드에 "@ResponseBody" 애너테이션을 붙이지 않아도 문자열, JSON 등을 전송할 수 있다. - View를 거치지 않고 HTTP ResponseBody에 직접 리턴 값을 담아 보내게 된다. @RequestMapping @RequestMapping(value = "/hello", method = RequestMethod.GET) public String hello() { return "Hello World"; } - 요청에 대해서 어떤 컨트롤러가 처리할지를 매핑하기 위한..