Which combination of annotations and code best achieves this using @PutMapping?
hard📝 Application Q15 of 15
Spring Boot - REST Controllers
You want to implement a REST API in Spring Boot that updates a product's price only if the product exists, otherwise returns 404. Which combination of annotations and code best achieves this using @PutMapping?
A@PutMapping("/products/{id}") public Product updatePrice(@RequestParam int id, @RequestBody Product p) {
p.setId(id);
return productService.save(p);
}