[Springboot] Controller 쿼리스트링과 주소변수매핑
아이티윌의 국비지원 [스프링부트 SNS 포토그램 프로젝트] 강의를 수강하며 정리한 내용입니다.
쿼리스트링과 주소변수매핑 실습
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@RestController
public class QueryPathController{
@GetMapping("/chicken")
public String chickenQuery(String type) {
return type + "배달갑니다. (쿼리스트링)";
}
@GetMapping("/chicken/{type}")
public String chickenPath(@PathVariable String type) {
return type + "배달갑니다. (주소 변수매핑)";
}
}
(쿼리스트링에 값이 없을 때)
(쿼리스트링에 값을 양념으로 줬을 때)
(주소에 값을 포함했을 때)
SpringBoot에서는 거의 주소 변수매핑 방식을 사용한다고 한다!
This post is licensed under CC BY 4.0 by the author.