RedirectAttributes 的使用
	@RequestMapping(value = "/redirecttest", produces = "application/json;charset=utf-8",method = RequestMethod.GET)
public String redirectest(HttpServletResponse response, RedirectAttributes attributes ) throws IOException {
Logs.info("redirectest");
attributes.addFlashAttribute("param1","value1");
attributes.addAttribute("param2","value2");
return "redirect:/redirectaccept"; } @RequestMapping(value = "/redirectaccept", produces = "application/json;charset=utf-8",method = RequestMethod.GET)
@ResponseBody
public String redirecaccept(HttpServletResponse response,
@ModelAttribute("param1") String param1,
@RequestParam("param2") String param2 ) {
Logs.info("redirecaccept1, param1 " + param1 + " param2: " +param2 );
return "ok";
}

 1、显示参数 

attributes.addAttribute("param2","value2");

   相当于才url后面增加param2=value2

2、隐藏参数
attributes.addFlashAttribute("param1","value1");

  本质上是将参数保存在session中,接收到后再将session删除。

												

Spring 4 中重定向RedirectAttributes的使用的更多相关文章

  1. spring mvc redirect 重定向 跳转并传递参数

    在项目中做form表单功能提交时,防止用户客户端后退或者刷新时重复提交问题,需要在服务端进行重定向跳转,具体跳转方式有以下几种方式: 公用代码: @RequestMapping(value=" ...

  2. Spring 梳理-跨重定向请求传递数据-Flash

    Spring MVC Flash Attribute 的讲解与使用示例 1. Spring MVC 3.1版本加了一个很有用的特性,Flash属性,它能解决一个长久以来缺少解决的问题,一个POST/R ...

  3. Http请求中Content-Type讲解以及在Spring MVC中的应用

    引言: 在Http请求中,我们每天都在使用Content-type来指定不同格式的请求信息,但是却很少有人去全面了解content-type中允许的值有多少,这里将讲解Content-Type的可用值 ...

  4. 在Spring Boot中使用Https

    本文介绍如何在Spring Boot中,使用Https提供服务,并将Http请求自动重定向到Https. Https证书 巧妇难为无米之炊,开始的开始,要先取得Https证书.你可以向证书机构申请证书 ...

  5. Spring MVC 中的 forward 和 redirect

    Spring MVC 中,我们在返回逻辑视图时,框架会通过 viewResolver 来解析得到具体的 View,然后向浏览器渲染.假设逻辑视图名为 hello,通过配置,我们配置某个 ViewRes ...

  6. SpringMvc(4-1)Spring MVC 中的 forward 和 redirect

    Spring MVC 中,我们在返回逻辑视图时,框架会通过 viewResolver 来解析得到具体的 View,然后向浏览器渲染.通过配置,我们配置某个 ViewResolver 如下: <b ...

  7. Spring MVC页面重定向

    以下示例显示如何编写一个简单的基于Web的重定向应用程序,这个应用程序使用重定向将http请求传输到另一个页面. 基于Spring MVC - Hello World实例章节中代码,创建创建一个名称为 ...

  8. Spring Security 中的过滤器

    本文基于 spring-security-core-5.1.1 和 tomcat-embed-core-9.0.12. Spring Security 的本质是一个过滤器链(filter chain) ...

  9. Http请求中Content-Type讲解以及在Spring MVC中的应用【转】

    完全引用自: http://blog.csdn.net/blueheart20/article/details/45174399#t1   此文讲得很清晰,赞! 引言: 在Http请求中,我们每天都在 ...

随机推荐

  1. ios 汽车品牌展示案例

    汽车组模型 // ZQRGroup.h #import <Foundation/Foundation.h> @interface ZQRGroup : NSObject /** *组标题 ...

  2. springsecurity基于数据库验证用户

    之前的springsecurity程序都是将数据存放在内存中的,通过 <security:user-service> <security:user name="user&q ...

  3. java学习笔记27(File类)

    File类: 定义:文件和目录径的抽象表示形式, Java中将路径或者文件封装成File对象 1.File类的静态成员变量 package com.zs.Demo2; import java.io.F ...

  4. Python基础2--Python简单数据类型

    python简单数据类型 1 list list的创建,使用[] a_list = [‘a’, ’b’, ‘c’] print a_list print a_list[0] #a 如果去list的最后 ...

  5. 2017ICPC南宁赛区网络赛 Overlapping Rectangles(重叠矩阵面积和=离散化模板)

    There are nnn rectangles on the plane. The problem is to find the area of the union of these rectang ...

  6. 跨交换机划分vlan配置

    实验要求:使两台交换机上同一vlan的主机能够通信,不同vlan的主机不能通信 拓扑如下: 涉及内容有: 1.vlan的创建和划分 2.端口trunk模式的设置 配置如下: Switch1 enabl ...

  7. LOD,听起来很牛逼的样子

    <!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - le ...

  8. saliency 2015-2016的论文、代码

    https://github.com/ArcherFMY/Paper_Reading_List 另外2013年之前的见chengmingming的benchmark主页.

  9. dubbo ActivateExtension

    对于集合类扩展点,比如:Filter, InvokerListener, ExportListener, TelnetHandler, StatusChecker等, 可以同时加载多个实现,此时,可以 ...

  10. Wood Chipping Text Animation

    Blender Tutorial: Wood Chipping Text Animationhttps://www.youtube.com/watch?v=YFmN7eTNfNw 文字建模 木板建模, ...