在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>
时间: 2024-11-09 05:47:08