[서버]/[SpringBoot Kotlin]
@RequestMapping을 사용하는 이유
Hevton
2022. 12. 1. 17:17
반응형
Controller 클래스 내에서, 경로를 설정할 때
공통된 경로들을 지정하는 데에 간단한 방법으로 @RequestMapping을 사용할 수 있다.
@RestController
@RequestMapping(value = "/hello")
public class HelloController {
@GetMapping()
public String helloGet(...) {
...
}
@PostMapping()
public String helloPost(...) {
...
}
@PutMapping()
public String helloPut(...) {
...
}
@DeleteMapping()
public String helloDelete(...) {
...
}
}
/hello로 GET 요청을 보내면
helloGet()이 실행되고
/hello로 DELETE 요청을 보내면
helloDelete()가 실행된다
아래 블로그가 너어어어무 잘 정리되어 있어서
모든 분들이 보셨으면 좋겠다..
반응형