Backend Development
Spring Boot
Subjective
Oct 03, 2025
How do you create a REST API in Spring Boot? Provide example.
Detailed Explanation
Use @RestController annotation:\n\n@RestController\npublic class UserController {\n @GetMapping("/users")\n public List getUsers() {\n return userService.getAllUsers();\n }\n \n @PostMapping("/users")\n public User createUser(@RequestBody User user) {\n return userService.save(user);\n }\n}
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts