求问关于 Springmvc中的 RedirectAttributes
假设访问网址 localhost/test 在controller中对应的方法如下:
@RequestMapping('/test')
public String test(RedirectAttributes redirectAttributes){
redirectAttributes.addFlashAttribute("info","操作成功");
return "result"; // 对应着result.ftl 的freemarker模板
}
上述代码 意思是加了一个瞬时消息${info},将这个消息带到 result模板生成的页面(假
设是 result.html)。
实际情况是:访问 localhost/test 时,确实跳转到 result.html页面,也显示了${info} 中
所带的消息 "操作成功" 。但是,此时如果用浏览器 回退 前进 按钮再次回到
result.html的时候,还是会显示 ${info} 中所带的消息 "操作成功" 。这说明了页面有
${info} 的缓存。
如何避免这种情况呢?即:只是第一次可以显示${info}的消息,显示完之后,无论怎
么按浏览器的回退 前进 到result.html页面,都不会再次显示 ${info}的消息。
求助!!