Does the user need to see the data placed on the model for the /first or /second page? If not, how about try changing:
return "/second";
to return "redirect:/second";
and
return "/third";
to return "redirect:/third";
If the user needs to see the data on /first or /second page for X time, how about doing the redirect from javascript?
Edited: How about flash attributes, see this post: reading flash attributes
@RequestMapping("/first")
String first(ModelMap model, final RedirectAttributes redirectAttributes) {
model.put("list", new ArrayList<String>());
redirectAttributes.addFlashAttribute("list", new ArrayList<String>());
return "redirect:/second";
}
@RequestMapping("/second")
String second(ModelMap model, final RedirectAttributes redirectAttributes) {
List list = (List) model.get("list");
list.add("A");
redirectAttributes.addFlashAttribute("list", list);
return "redirect:/third";
}
@RequestMapping("/third")
String third(ModelMap model, final RedirectAttributes redirectAttributes) {
List list = (List) model.get("list");
list.add("B");
redirectAttributes.addFlashAttribute("list", list);
return "end";
}