In my web page after a chain of actions the client sees the details of the reservation. The method used to populate the data to be displayed in these details also stores the reservation in the database:
@RequestMapping(params = { "complete" }, method = RequestMethod.POST, produces = "text/html")
public String completeReservation(Model uiModel, HttpServletRequest httpServletRequest, ...) {
// ...
reservation.persist();
// ...
uiModel.addAttribute(...);
uiModel.addAttribute(...);
// ...
return "reservations/success";
}
The success
page is the one that displays the details.
However, if I refresh the page another reservation entry is stored and I don't want this to happen.
Any suggestions on how I should approach this problem?
Commonly this is solved by making two actions - one that's doing the business (stores a reservation) and second one that shows the result to the user.
After successfull storing of reservation in the first action, redirect to the second one. From user point of view it will be one action and if he hits the reload button, only view action is performed again.