I do not understand what to use and when.
There are two pages - intro.jsp (1) and booksList.jsp (2). For each page created one controller class.
On the first page there is a button that opens the second page:
<form method="GET" action="/request-list"> <input type="submit"/> </form> The first question : I'm not sure about the correctness of this button - it seems to work OK, but how to do it correctly so that when opening there is no question mark at the end of the URL.
Second :
When a button is pressed (the button on the first page), the annotated method (the controller for the first page) is triggered:
@RequestMapping(value = "request-list") But the controller class, which is responsible for the actions with the second page:
@RequestMapping(value = "/books") @Controller public class BooksListController { /** * запрос на страницу-список */ @RequestMapping public String booksList() { return "jsp/books/booksList"; } } And what to return by this method? That is, how do I make the transition from the first to the second page? How to write:
return "redirect:/books";returnedhttp://localhost:8080/books?return "jsp/books/booksList";returnedhttp://localhost:8080/request-list?return "forward:/books";returnedhttp://localhost:8080/request-list?
It seems that the result is the same (page 2 opens), well, except for the URL in the browser - they are different. For what cases what to use?