Skip to Main Content
Spring MVC Beginner's Guide
book

Spring MVC Beginner's Guide

by Amuthan Ganeshan
June 2014
Beginner to intermediate content levelBeginner to intermediate
304 pages
7h 25m
English
Packt Publishing
Content preview from Spring MVC Beginner's Guide

Time for action – adding the product details page

So far in our product listing page, we have only shown product information such as the product's name, description, price, and available units in stock. However, we haven't shown information such as the manufacturer's name, category, product ID, and so on. Let's create a product details page displaying this information as follows:

  1. Open the ProductController class and add one more request mapping method as follows:
    @RequestMapping("/product")
    public String getProductById(@RequestParam("id") String productId, Model model) {
      model.addAttribute("product", productService.getProductById(productId));
      return "product";
    }
  2. Add one more JSP view file called product.jsp under the directory src/main/webapp/WEB-INF/views/ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Spring MVC Beginner's Guide - Second Edition

Spring MVC Beginner's Guide - Second Edition

Amuthan Ganeshan
Spring MVC: Designing Real-World Web Applications

Spring MVC: Designing Real-World Web Applications

Shameer Kunjumohamed, Hamidreza Sattari, Alex Bretet, Geoffroy Warin

Publisher Resources

ISBN: 9781783284870Supplemental Content