Springboot

@PathVariable 활용한 GetMapping 사용법

수아파파's 2023. 9. 17. 19:39
반응형

 

@GetMapping("/{name}") 
public String helloWorld(@PathVariable String name) { 
   return "Hello " name; 
}

위와 같이 @PathVariable을 사용하여 경로 변수를 사용할 수 있습니다. 예를 들어, /hello/john 으로 요청하면 "Hello john"이 출력됩니다.

반응형