Spring MVC 3.1 では、次のことができます。
@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";
}
次に、ビューにフラッシュ メッセージを表示します。
<p>${flashSuccessMsg}</p>
しかし、フラッシュ メッセージのリストを取得してから、ビューでこれを反復処理したいと思います。
これは可能ですか?
フラッシュメッセージに名前を付けていない場合redirectAttributes.addFlashAttribute("Update Successful");
、ビューでそれを取得するにはどうすればよいですか?