O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – showing the products based on filter

Consider a situation where we want to filter the product list based on the brand and category variables. For example, you want to list all the products that fall under the category laptop and tablets and from the manufacturers google and dell. With the help of the matrix variables, we can form a URL to bind the brand and category variables' values into the URL as follows:

http://localhost:8080/webstore/products/filter/ByCriteria;brand=google,dell;category=tablet,laptop

Let's map this URL to a handler method with the help of the @MatrixVariable annotation:

  1. Open the ProductRepository interface and add one more method declaration, getProductsByFilter, on it:
    Set<Product> getProductsByFilter(Map<String, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required