Using URI template patterns

In the previous chapters, you saw how to map a particular URL to a Controller's method; for example, if we entered the URL http://localhost:8080/webstore/market/products, we would map that request to the list method of ProductController and list all the product information in the web page.

What if we want to list only a subset of products based on category, for instance, if we want to display only the products that fall under the category of laptops? If the URL entered is http://localhost:8080/webstore/market/products/Laptop, and similarly if the URL is http://localhost:8080/webstore/market/products/Tablet, we will like to show only tablets on the web page.

One way to do this is to have a separate request mapping method ...

Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.