页面请求:

<a href="user/user?type=1">传参数</a>

action:

     public Integer type;

     public String execute(){
return SUCCESS;
// return "test";
} public Integer getType() {
return type;
} public void setType(Integer type) {
this.type = type;
}

stuts.xml中把type这个参数传到其他的jsp页面:

 <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
<!-- $用来在配置文件里面往值栈 valueStack 里取值 -->
<result type="redirect">/user_success.jsp?t=${type}</result>
<result name="test" type="chain">test</result>
</action>

注意:一次request共享一个值栈,要想跨request,比如重定向跳转了,那么就可以通过这种方式传递参数。

jsp页面:

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>user_success</title>
<base href="<%=basePath%>"/>
</head>
<body>
<h1>user success.</h1>
值栈中没值,因为是通过参数传过来的,通过redirect的不在同一个request中<br>
from valuestack:<s:property value="t"/><br>
所以只能通过actionContext来取,具体是parameters
from actioncontext:<s:property value="#parameters.t"/>
<s:debug></s:debug>
</body>
</html>

结果:

链接: http://pan.baidu.com/s/1mic8CZm 密码: q5mh

最新文章

  1. jquery mobile button样式设置
  2. 安装ESXi5.5遇到Relocating modules and starting up the kernel的处理
  3. Windows NT驱动程序的基本结构和实例
  4. 机器人操作系统(ROS)教程4:ROS的框架【转】
  5. XidianOJ 1097 焊板子的xry111
  6. Lucene.net入门学习(结合盘古分词)
  7. 2013 Multi-University Training Contest 3
  8. iOS开发经验总结(上)
  9. oracle3
  10. Android -- getSystemService
  11. Java客户端Jedis的八种调用方式
  12. java循环
  13. POJ-1861-NETWORK 解题报告
  14. mysql外键
  15. Zabbix 配置监控主机
  16. WebService接口定义及调用
  17. 6.安装pyhook报错is not a supported wheel on this platform
  18. Js冒泡事件详解及阻止
  19. bzoj3473字符串&amp;bzoj3277串
  20. flex 和bison的安装和使用

热门文章

  1. 查看详细linux系统信息的命令和方法
  2. freemarker常用标签解释
  3. P2905 [USACO08OPEN]农场危机Crisis on the Farm
  4. 牛客Professional Manager(并查集)
  5. SQL Server 清理日志
  6. oracle数据库代码块
  7. TCP/IP协议&lt;一&gt;
  8. numpy初用
  9. 树形dp学习
  10. 修改linux文件权限命令