Spring Boot API 예시

목차

Spring Boot API 예시

@RestController
@RequestMapping("/mapping/users")
public class MappingClassController {

@GetMapping
public String user(){
return "get users";
}

@PostMapping
public String addUser(){
return "post user";
}

@GetMapping("/{userId}")
public String findUser(@PathVariable String userId){
return "get suerId = " + 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;
}
}
Share