Chapter 3, Control Your Store with Controllers

Questions

Answers

If you imagine a web application called Library with the following request mapping on a Controller class level and in the method level, which is the appropriate request URL to map the request to the books method?

@RequestMapping("/books")    
public class BookController {    
...    
    
@RequestMapping(value = "/list")    
public String books(Model model) {    
...    

1. http://localhost:8080/library/books/list

Similarly, suppose we have another handler method called bookDetails under BookController as follows, what URL will map to that method?

@RequestMapping    
public String details(Model model) {    
...   

2. http://localhost:8080/library/books

If we have a web application called webstore with ...

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.