- 스프링에서 지원하는 API를 사용하여 요청 매핑을 받을 수 있다
- RequestMapping을 Class에 어노테이션 해서 디폴트 URL값을 인식해준다
- GET방식
@GetMapping
public String user() {
return "get users";
}
@PostMapping
public String addUser() {
return "post user";
}
@GetMapping("/{userId}")
public String findUser(@PathVariable String userId) {
return "get userId" + userId;
}
@PatchMapping("/{userId}")
public String updateUser(@PathVariable String userId) {
return "update userId" + userId;
}
@DeleteMapping("/{userId}")
public String deleteUser(@PathVariable String userId) {
return "delete userId" + userId;
}
댓글