带参数的结果集:
配置文件: <result type="redirect">/user_success.jsp?t=${type}</result>
jsp调用 :
from valuestack: <s:property value="t"/><br/> //取不到,因为客户端跳转后 以前action的值都没有了.
from actioncontext: <s:property value="#parameters.t"/>
1. jsp显示文件:]
<ol> <li><a href="user/user?type=1">传参数</a></li> </ol>
2. struts.xml配置文件:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true" /> <package name="user" namespace="/user" extends="struts-default"> <action name="user" class="com.bjsxt.struts2.user.action.UserAction"> <result type="redirect">/user_success.jsp?t=${type}</result> </action> </package> </struts>
3. action文件:
package com.bjsxt.struts2.user.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private int type; public int getType() { return type; } public void setType(int type) { this.type = type; } @Override public String execute() throws Exception { return "success"; } }
4. user_success.jsp:
<body> User Success! from valuestack: <s:property value="t"/><br/> 取不出来, 因为客户端跳转, 值栈已清空 from actioncontext: <s:property value="#parameters.t"/> <s:debug></s:debug> </body>