I have the following sequence.
View1 (POST form) -> PostController (create model and redirect) -> GetController -> View2
I am using RedirectAttributes to pass model between PostController and GetController, I have
class PostController {
public String mypost(..., final RedirectAttributes redirectAttrs){
//create model
redirectAttrs.addFlashAttribute("model", model);
return "redirect:myget";
}
}
and
@SessionAttributes("model")
class GetController {
public ModelAndView myget(@ModelAttribute("model") final Model model){
ModelAndView mav = new ModelAndView("view2");
mav.addObject("model", model);
return mav;
}
}
When a user opens multiple tabs on a browser, then refresh the earlier tab, it will be overwritten by the latter opened tab.
I would like each tab to be independent, hope someone point me to the right direction.
Thanks.
Edit
The problem is at @SessionAttributes("model"). I use it because "Flash attributes are saved temporarily before the redirect (typically in the session) to be made available to the request after the redirect and removed immediately.". Thus, tabs are overwritten each other because the model in session is updated.