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如何支持临时属性信息

spring mvc RedirectAttributes的更多相关文章

  1. Spring MVC RedirectAttributes的用法解决办法

    Spring MVC RedirectAttributes的用法很久没发过技术贴了,今天对于一个问题纠结了2小时,遂放弃研究用另一种方法解决,奈何心中一直存在纠结,发帖求解 我先解释下什么是Redir ...

  2. Spring MVC RedirectAttributes取值方法

    RedirectAttributes是Spring mvc 3.1版本之后出来的一个功能,专门用于重定向之后还能带参数跳转的他有两种带参的方式:第一种: attr.addAttribute(" ...

  3. spring mvc重定向方法

    一.不带参数,直接重定向到另一个地址: 返回String直接跳转,如: @RequestMapping(value = "/filehandle") public String u ...

  4. spring mvc 请求转发和重定向(转)

    spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...

  5. spring mvc controller间跳转 重定向 传参 (转)

    转自:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ 1. 需求背景     需求:spring MVC框架contr ...

  6. spring mvc 4.3.2 + mybatis 3.4.1 + mysql 5.7.14 +shiro 幼儿园收费系统 之 登录

    如标题,用spring mvc 4.3.2+mybatis 3.4.1 + mysql 5.7.14 +shiro 开发了一个用于幼儿园的管理系统. 功能模块 包括 账号,角色,权限管理. 幼儿档案管 ...

  7. Spring MVC 学习总结(六)——Spring+Spring MVC+MyBatis框架集成

    与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和 ...

  8. Spring MVC 学习总结(三)——请求处理方法Action详解

    Spring MVC中每个控制器中可以定义多个请求处理方法,我们把这种请求处理方法简称为Action,每个请求处理方法可以有多个不同的参数,以及一个多种类型的返回结果. 一.Action参数类型 如果 ...

  9. Spring MVC 学习总结(二)——控制器定义与@RequestMapping详解

    一.控制器定义 控制器提供访问应用程序的行为,通常通过服务接口定义或注解定义两种方法实现. 控制器解析用户的请求并将其转换为一个模型.在Spring MVC中一个控制器可以包含多个Action(动作. ...

随机推荐

  1. OpenGL ES入门09-GLSL实现常见特效 [转]

    本文转自简书,原文地址http://www.jianshu.com/p/e4a8c83cd37 本文是关于OpenGL ES的系统性学习过程,记录了自己在学习OpenGL ES时的收获. 这篇文章的目 ...

  2. vue-cli 配置路由之间跳转传递参数

    1.有2种方式去传参,如下代码: <template> <div> <div>这里是首页</div> <router-link :to=" ...

  3. limit是mysql的语法

    select * from table limit m,n 其中m是指记录开始的index,从0开始,表示第一条记录 n是指从第m+1条开始,取n条. , 即取出第3条至第6条,4条记录 转自:htt ...

  4. ocx注册

    (1)服务器OCX注册 (2)IE浏览器,站点加入可信任站点. internet 选项->安全->可信任站点.把“对该区域中的所有站点要求服务器验证(https:)” 前面的勾去掉 (3) ...

  5. 为 sublime text3 添加 github 上的插件

    1.CMD+SHIFT+P ---> ADD REPOSITORY 输入 github 上的地址 https://github.com/akira-cn/sublime-gbk 2.CMD+SH ...

  6. Nutch的发展历程(转)

    2002年8月由Doug Cutting发起,托管于Sourceforge,之后发布了0.4.0.5.0.6三个版本 2004年9月Oregon State University(俄勒冈州立大学)采用 ...

  7. 网页会计系统 FrontAccounting

    FrontAccounting (FA)是一个针对企业ERP供应链的网页会计系统.FA 允許多使用者.多語系和多國貨幣. FA允许多使用者.多语系和多国货币.FA接续OpenAccounting (O ...

  8. 学习-短信的上行(MO)和下行(MT)详解

    基础知识: SP服务提供商: 通常是指在移动网内运营增值业务的社会合作单位, 它们建立与移动网络建立相连的服务平台, 为手机用户提供一系列信息服务, 如:娱乐.游戏.短信.彩信.WAP.彩铃.铃声下载 ...

  9. golang中使用mongodb的操作类以及如何封装

    mgo简介 mongodb官方没有关于go的mongodb的驱动,因此只能使用第三方驱动,mgo就是使用最多的一种. mgo(音mango)是MongoDB的Go语言驱动,它用基于Go语法的简单API ...

  10. 【转】打造自己的视频会议系统 GGMeeting(附送源码)

    原文地址:http://www.cnblogs.com/justnow/p/4487201.html 自从在博客园发布开源即时通信系统GG(QQ高仿版)以来,结识了很多做IM的朋友,然后我和我的伙伴们 ...