@RestController
@RequestMapping("/api/products")
public class ProductController {
@GetMapping
public List<Product> getAll() {
return productService.findAll(); // auto-serialized to JSON
}
}@RestController
A convenience annotation that combines @Controller and @ResponseBody — every method's return value is serialized straight to the HTTP response body (usually JSON).