Spring Boot를 이용한 REST API 구현 예시
// 필요한 import문 생략 @RestController @RequestMapping("/api") public class ApiController { @Autowired private UserService userService; @GetMapping("/users") public List getAllUsers() { return userService.getAllUsers(); } @GetMapping("/users/{id}") public ResponseEntity getUserById(@PathVariable Long id) { User user = userService.getUserById(id); if (user != null) { return ResponseEntity.ok(user); } ..
PROGRAMMING
2024. 2. 4. 11:10