This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
No because you are using Annotations, you can have all three pages call three different methods in your controller
@RequestMapping() has an attribute called requestMethod or method you can set one to RequestMethod.POST and the other to RequestMethod.GET but both have the same URL value.
Mark Spritzler wrote:No because you are using Annotations, you can have all three pages call three different methods in your controller
@RequestMapping() has an attribute called requestMethod or method you can set one to RequestMethod.POST and the other to RequestMethod.GET but both have the same URL value.
Mark
same url with same jsp?
so the get will net to have the information of the post...
Mark Spritzler wrote:No because you are using Annotations, you can have all three pages call three different methods in your controller
@RequestMapping() has an attribute called requestMethod or method you can set one to RequestMethod.POST and the other to RequestMethod.GET but both have the same URL value.
Mark
same url with same jsp?
so the get will net to have the information of the post...
Yes, I would assume the same jsp page. I also would assume your get is to load the page and the post is after the user clicks submit.
So I type
www.mysite.com/mywebapp/customer.jsp?id=5 in my browser. That will do a get call the one method in my controller that is mapped to GET, It say passes in the RequestParameter of five. In my method code I lookup customer #5 and fill in a Customer object and set it in the Model. The jsp renders and goes to the client browser with the form showing with that customer information. The user changes some data then clicks the Submit button, which submits to the same URL but this time it is a POST. The method in the controller then receives the Customer and sends down to the CustomerService and CustomerRepository to save the updated Customer.
Or with the same URL with no parameter, the same Controller method that is mapped to the GET just creates a new Customer and adds it to the Model. The same jsp page gets rendered with an empty form but a Customer object backing it. The user enters the new data, clicks the Submit button, which submits to the same URL but this time it is a POST. The method in the controller then receives the Customer and sends down to the CustomerService and CustomerRepository to insert the new Customer.