1
JavaAdvanced#spring
@Controller returns view names to be resolved by a view resolver (for server-rendered pages). @RestController combines @Controller and @ResponseBody, automatically serializing return values (usually to JSON) directly into the HTTP response body.
@RestController
class ApiController {
@GetMapping("/users")
List<User> getUsers() { return userService.findAll(); } // serialized to JSON automatically
}