参考链接如下:

http://bbs.csdn.net/topics/391034118?page=1

自己的示例程序:

详细页面提交一个修改动作,修改完成后跳转到检索页面,把检索条件重新赋值给检索页面。

本地页面

    <input type="hidden" name="startDate" value="${(requestDto.startDate)!""}">
<input type="hidden" name="endDate" value="${(requestDto.endDate)!""}">

本地controller

private static final String SEARCH_PAGE = "redirect:/list/search.do";
@RequestMapping(value = "/update", method=RequestMethod.POST)
public String update(RequestDto requestDto,ModelMap modelMap,RedirectAttributes attr) {
/*这段代码就不贴出来了*/
setRedirectParam(requestDto, attr);
return SEARCH_PAGE;
} private void setRedirectParam(RequestDto requestDto,RedirectAttributes attr){
attr.addAttribute("startDate", requestDto.getStartDate());
attr.addAttribute("endDate", requestDto.getEndDate());
}

检索页面

    <input type="text" name="startDate" value="${(requestDto.startDate)!""}">
<input type="text" name="endDate" value="${(requestDto.endDate)!""}">

检索controller

 @RequestMapping("/search")
public String search(RequestDto requestDto,DalPage pagination,ModelMap modelMap) { }

据参考的帖子,参数传递除了attr.addAttribute();

还有一种方式:attr.addFlashAttribute();使用这个的时候一般用来传递处理结果。

本地页面同上

本地controller

private static final String SEARCH_PAGE = "redirect:/list/search.do";
@RequestMapping(value = "/update", method=RequestMethod.POST)
public String update(RequestDto requestDto,ModelMap modelMap,RedirectAttributes attr) {
/*这段代码就不贴出来了*/
setRedirectParam(requestDto, attr);
return SEARCH_PAGE;
} private void setRedirectParam(RequestDto requestDto,RedirectAttributes attr){
attr.addFlashAttribute("successCode", requestDto.getStartDate());
}

检索页面

<script type="text/javascript">
window.onload=function(){
if(""!="${(successCode)!""}"){
alert("${(successCode)!""}");
}
}
</script>

检索controller可以不用接参数。且可以通过如下形式查看

@RequestMapping("/search")
public String search(HttpServletRequest httpRequest) {
Map<String, ?> map=RequestContextUtils.getInputFlashMap(httpRequest);
}

map里面存放的就是闪存的值。

然后就是混合使用

attr.addAttribute("startDate", requestDto.getStartDate());
attr.addAttribute("endDate", requestDto.getEndDate());
attr.addFlashAttribute("successCode", "3001");

这样做的话,页面那边是取不到闪存的值得,只能取到get提交参数。

spring mvc 重定向传参的更多相关文章

  1. Spring MVC URL传参

    Spring MVC 学习 之 - URL参数传递   在学习 Spring Mvc 过程中,有必要来先了解几个关键参数:    @Controller: 在类上注解,则此类将编程一个控制器,在项目启 ...

  2. spring MVC 尝试传参json(应用部分)

    spring 3.1后增加新的注解:@Requestbody,@Responsebody, 暂不论Requestdody, 若想让后端代码直接返回json字符串,可使用@Responsebody, 用 ...

  3. 解决Spring MVC前台传参中文乱码问题

    在web.xml文件中配置字符编码过滤器: <filter> <filter-name>CharacterEncoding</filter-name> <fi ...

  4. Spring MVC POJO传参方式

    有两POJO类 Address.java package com.proc; public class Address { private String province; private Strin ...

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

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

  6. SpringMVC归纳-1(model数据模型与重定向传参技术)

    要点: model是一个Map结构的数据模型,能重定向时传递数据(拼接URL),但不安全,主要用于渲染前端页面,配合Thymeleaf填充html里面里设置好的参数. @RequestParam用来获 ...

  7. Spring MVC上传文件

    Spring MVC上传文件 1.Web.xml中加入 <servlet> <servlet-name>springmvc</servlet-name> <s ...

  8. Spring MVC 上传文件

    Spring MVC上传文件需要如下步骤: 1.前台页面,form属性 method设置为post,enctype="multipart/form-data"  input的typ ...

  9. jsp内部传参与重定向传参

    1 重定向地址栏会发生改变,因为它会发送两次请求,内部转发,地址栏不会发生改变,因为它只有一个请求2 重定向不能获取上一次请求中的参数,而内部转换可以3 内部转发可以访问WEB-INF下的资源,重定向 ...

随机推荐

  1. SQL Server 自定义字符串分割函数

    一.按指定符号分割字符串,返回分割后的元素个数,方法很简单,就是看字符串中存在多少个分隔符号,然后再加一,就是要求的结果(标量值函数)   create function Func_StrArrayL ...

  2. struts2 类型转换

    概述 从一个 HTML 表单到一个 Action 对象, 类型转换是从字符串到非字符串. 在 struts2 中, 把请求参数映射到 action  属性的工作由 Parameters 拦截器负责, ...

  3. xcode6 ios launchimage

    1.点击Image.xcassets 进入图片管理,然后右击,弹出"New Launch Image" 2.右侧的勾选可以让你选择是否要对ipad,横屏,竖屏,以及低版本的ios系 ...

  4. get( )与getline( )区别

    get与getline区别不是很大,但一个明显的区别是get遇到 '\n '字符后便返回,这是 '\n '还在缓冲区中,所以下次读出来的将是 '\n ',而getline遇到 '\n '也返回,但它会 ...

  5. Object Oriented Programming python

    Object Oriented Programming python new concepts of the object oriented programming : class encapsula ...

  6. linux之开发板与宿主机-GDB远程调试

    平台: redhat9.0 下载 gdb-5.3.tar.gz 解压 gdb-5.3.tar.gz: #tar vzxf gdb-5.3.tar.gz 配置文件# ./configure - targ ...

  7. Helloworld程序的创建以及配置文件的讲解

    创建项目. create Project 选择创建的Project类别以及使用的SDK,可能SDK需要配置或者修改配置. 这个页面是问你是否使用模板创建. Command Line App 会自动创建 ...

  8. 移动设备和SharePoint 2013 - 第3部分:推送通知

    博客地址:http://blog.csdn.net/foxdave 原文地址 在该系列文章中,作者展示了SharePoint 2013最显著的新功能概观--对移动设备的支持. 该系列文章: 移动设备和 ...

  9. C#特性

    一.概念:C#的特性也是一个类,继承自System.Attribute,用于描述类.方法.字段等 二.类型:   2.1  .net中特性用来处理多种问题,比如序列化.程序的安全特性.防止即时编译器对 ...

  10. MySQL表的增删改查和列的修改(二)

    一.使用Like模糊查找搜索前缀为以“exam_”开头的表名 show tables like 'exam_%' ; 语句结束符号是:也是用\G来表示 二.MySQL表的CRUD 2.1 创建表: C ...