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:

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?

  • one
    forward is a server transition to another redirect controller - sends http with code 302 and redirects to another url. The second is often used as protection against F5. Let's say when paying so that it does not happen again. - Vladislav Pyatkov
  • SO I have already read and written there the same thing. Do I understand correctly that redirect should be used after a POST request? - arg
  • Yes. See ru.wikipedia.org/wiki/Post/Redirect/Get - Slava Semushin

0