관리 메뉴

CASSIE'S BLOG

get API 본문

PROGRAMMING/JAVA SPRING

get API

ITSCASSIE1107 2023. 5. 19. 14:17

url 명령규칙 

언더바는 안 쓰고 하이픈을 쓴다. 

 

 

// http://localhost:8080/api/v1/get-api/variable1/{String }
@GetMapping(value = "/variable1/{variable}")
public String getVariable1(@PathVariable String variable) {
return variable;
}

 

 

 

// http://localhost:8080/api/v1/get-api/request2?key1=value1&key2=value2
@GetMapping(value = "/request2")
public String getRequestParam2(@RequestParam Map<String, String> param) {
StringBuilder sb = new StringBuilder();

param.entrySet().forEach(map -> {
sb.append(map.getKey() + " : " + map.getValue() + "\n");
});

 

 

코드 및 자료 출처 (어라운드허브스튜디오): 

(52) GET API 만드는 다양한 방법 실습 [ 스프링 부트 (Spring Boot) ] - YouTube 

반응형

'PROGRAMMING > JAVA SPRING' 카테고리의 다른 글

mySQL 부터  (0) 2023.06.03
[비공개] 파트3  (0) 2023.05.28
SPRING BOOT 구조 정리  (0) 2023.05.24
PUT API & Delete API & ResponseEntity  (0) 2023.05.23
[get API] entrySet() 메소드 & 람다 표현식  (1) 2023.05.19