In Spring MVC 3.1 I can do:
@RequestMapping(value = "{id}/edit", method = RequestMethod.POST)
public String update(Category category, @PathVariable Integer id,
@RequestParam("childrenOrder") int[] childrenOrder,
RedirectAttributes redirectAttributes) {
if (!id.equals(category.getCategoryId())) throw new IllegalArgumentException("Attempting to update the wrong category");
categoryMapper.updateByPrimaryKey(category);
redirectAttributes.addFlashAttribute("flashSuccessMsg", "Update Successful"); //ADD FLASH MESSAGE
return "redirect:/admin/categories.html";
}
And then show the flash message in the view:
<p>${flashSuccessMsg}</p>
But I would rather have a list of flash messages, and then iterate over this in the view.
Is this possible?
If I do: redirectAttributes.addFlashAttribute("Update Successful");
i.e. I don't name the flash message, how do I then retrive it in the view?