码迷,mamicode.com
首页 > 编程语言 > 详细

spring mvc redirect设置FlashAttribute

时间:2015-05-19 12:29:10      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

在Controller中设置:

    @RequestMapping("/redir")
    public String redir(Model model, RedirectAttributes ra) {
        ra.addFlashAttribute("test", "测试数据");
        return "redirect:/user/users";
    }

在jsp中使用el表达式接收:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>用户列表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css" href="<%=basePath %>resources/css/main.css">
</head>

<body>
     ${test }
    <br />
     
</body>
</html>

 

spring mvc redirect设置FlashAttribute

标签:

原文地址:http://www.cnblogs.com/stono/p/4514100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!