RedirectAttributes を使用できます。コントローラがリダイレクト シナリオの属性を選択するために使用できる Model インターフェイスの特殊化。
public interface RedirectAttributes extends org.springframework.ui.Model
さらに、このインターフェイスは、「Flash 属性」を保存する方法も提供します。Flash 属性は FlashMap にあります。
FlashMap : FlashMap は、あるリクエストが別のリクエストで使用するための属性を格納する方法を提供します。これは、ある URL から別の URL にリダイレクトするときに最も一般的に必要です。簡単な例は
@RequestMapping(value = "/accounts", method = RequestMethod.POST)
public String handle(RedirectAttributes redirectAttrs) {
// Save account ...
redirectAttrs.addFlashAttribute("message", "Hello World");
return "redirect:/testUrl/{id}";
}
参考資料・詳細情報はこちら