Wrong request

Report a typo

You have the following object in your application:

public class Product {

    private int id;
    private String name;

    //constructors, getters, and setters
}

The controller is coded as follows:

@RestController
public class ProductController {
    private final List<Product> productList = List.of(
        new Product(1, "Milk"),
        new Product(2, "Sausages"),
        new Product(3, "Butter")
    );

    @GetMapping("/products/{id}")
    public Product getProduct(@PathVariable int id) {
        return productList.get(id - 1);
    }
}

What will we receive if the request GET /products/6 will be given to the server?

Select one option from the list
___

Create a free account to access the full topic