Loading

spring mvc redirect设置FlashAttribute

在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>

 

posted @ 2015-05-19 11:27  stono  阅读(404)  评论(0编辑  收藏  举报