Book Image

Spring MVC: Beginner's Guide - Second Edition

By : Amuthan Ganeshan
Book Image

Spring MVC: Beginner's Guide - Second Edition

By: Amuthan Ganeshan

Overview of this book

Spring MVC helps you build flexible and loosely coupled web applications. The Spring MVC Framework is architected and designed in such a way that every piece of logic and functionality is highly configurable. Also, Spring can integrate effortlessly with other popular web frameworks such as Struts, WebWork, Java Server Faces, and Tapestry. The book progressively teaches you to configure the Spring development environment, architecture, controllers, libraries, and more before moving on to developing a full web application. It begins with an introduction to the Spring development environment and architecture so you're familiar with the know-hows. From here, we move on to controllers, views, validations, Spring Tag libraries, and more. Finally, we integrate it all together to develop a web application. You'll also get to grips with testing applications for reliability.
Table of Contents (20 chapters)
Spring MVC Beginner's Guide - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

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 in the Controller for every unique category. But it won't scale if we have hundreds of categories; in that case we have to write hundreds of request mapping methods in the Controller. So how do we do that in an elegant way?

The Spring MVC URI template...