CHAPTER 5: Building Java Web Applications with Spring Web MVC 249
Let’s replace the interface-based controller in Listing 5-42 with an annotations-based controller.
Listing 5-44 illustrates the annotations-based BookController.
Listing 5-44. Annotations-Based BookController
- package com.apress.bookstore.controller;
- import com.apress.bookstore.service.BookService;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.servlet.ModelAndView;
- @Controller
- @RequestMapping("/list_book.html")
Figure 5-20. Directory structure of the bookstore application