org.springframework.web.servlet.mvc.support.RedirectAttributes

org.springframework.web.servlet.mvc.support.RedirectAttributes to specify the exact set of attributes to use in case of a redirect and also to add flash attributes (attributes stored temporarily on the server-side to make them available to the request after the redirect). RedirectAttributes is used instead of the implicit model if the method returns a "redirect:" prefixed view name or RedirectView.

  该类用来存储指定的属性集合,其中包括重定向的一些属性参数和一些临时属性信息(这些属性存储在服务器的临时空间中,为了使它们在重定向后对于request依然可以使用)。当方法中返回一个"redirect:"前缀的视图名或者重定向视图,RedirectAttributes被用来替代隐含的model属性。

By default all model attributes are considered to be exposed as URI template variables in the redirect URL. Of the remaining attributes those that are primitive types or collections/arrays of primitive types are automatically appended as query parameters.

  默认情况下,所有模型属性都被认为是在重定向的URL中暴露URI模版变量的。剩下的那些原始类型属性,或者原始类型的集合或数组属性,自动追加在后面作为查询参数。

In annotated controllers however the model may contain additional attributes originally added for rendering purposes (e.g. drop-down field values). To gain precise control over the attributes used in a redirect scenario, an @RequestMapping method can declare an argument of type RedirectAttributes and use it to add attributes for use in RedirectView. If the controller method does redirect, the content of RedirectAttributes is used. Otherwise the content of the default Model is used.

  然而在注解的控制类中,model可能包含最初添加的额外属性以用来提交目的。为了获取精确的控制,通过重定向方案中的属性信息,一个@RequestMapping方法能够声明一个RedirectAttributes类型的参数,并将该属性用在RedirectView中。如果这个控制器重定向了,RedirectAttributes中的内容会被使用。否则使用的是默认model中的内容。

The RequestMappingHandlerAdapter provides a flag called "ignoreDefaultModelOnRedirect" that can be used to indicate the content of the default Model should never be used if a controller method redirects. Instead the controller method should declare an attribute of type RedirectAttributes or if it doesn’t do so no attributes should be passed on to RedirectView. Both the MVC namespace and the MVC Java config keep this flag set to false in order to maintain backwards compatibility. However, for new applications we recommend setting it to true

  RequestMappingHandlerAdapter提供了一个标识名为”ignoreDefaultModelOnRedirect",能够用来指明,当一个控制器方法重定向时,默认model中哪些内容内容应该永远不被使用。相反的控制器方法应该声明一个RedirectAttribute属性,或者当它不这么做时,应该没有属性被传递给RedirecView。mvc命名空间和mvcjava配置需要声明这个标识为false,目的是保留向后的兼容性。然而对于新的应用我们推荐设置为true。

The RedirectAttributes interface can also be used to add flash attributes. Unlike other redirect attributes, which end up in the target redirect URL, flash attributes are saved in the HTTP session (and hence do not appear in the URL). The model of the controller serving the target redirect URL automatically receives these flash attributes after which they are removed from the session. See Section 17.6, “Using flash attributes” for an overview of the general support for flash attributes in Spring MVC.

这个RedirectAttributes接口可以被用来添加临时的属性。和那些在目标重定向URL结束的重定向参数不同,临时属性被记载在session中(今后不会在rul中出现)。控制器的model提供了目标重定向地址自动接收这些零时参数,当他们从session中被移除时。17.6章节讲述springmvc如何支持临时属性信息

最新文章

  1. C#可空类型
  2. C++之路进阶codevs1242(布局)
  3. VR视频外包公司(长年承接虚拟全景外包、虚拟现实视频外包)
  4. merge into在oracle10g和oracle 11g中的使用差别一
  5. PHP如何实现页面静态化
  6. autoit 中_GUICtrlStatusBar_SetBkColor失效的解决办法
  7. 显示pdf
  8. .NET中的计时器控件Timer
  9. python datetime 时间日期处理小结
  10. uc/os 任务删除
  11. 在picture library中取某一图片的大图、小图
  12. CentOS7 + Nginx1.13.5 + PHP7.1.10 + MySQL5.7.19 源码编译安装
  13. 三级菜单python写法(递归写法)
  14. 爬虫豆瓣top250项目-开发文档
  15. java编码与解码(一)
  16. Redis——windows下如何连接Linux(centos7.x)虚拟机的Redis——【二】
  17. [JVM-2]常用JVM命令参数
  18. 图像特征匹配,sift,surf法
  19. js中加“var”和不加“var”的区别
  20. Gym101485: NWERC 2015(队内第6次训练)

热门文章

  1. ArcGIS Server 10中的切图/缓存机制深入【转】
  2. 使用FreeMarker的Web Project例子
  3. activemq持久化配置,设置为主从模式(带复制的主从模式,应用mysql数据库)
  4. php.in
  5. 在 TDA 工具里看到 Java Thread State 的第一反应是
  6. 使用ant运行testng的testng.xml并且使用testng-results.xsl美化结果
  7. 请远离include_once和require_once[转]
  8. Git学习笔记二--工作区和暂存区
  9. python错误处理/调试/单元测试/文档测试
  10. 算法笔记_063:蓝桥杯练习 送分啦(Java)