您的位置:首页 > 编程语言 > Java开发

struts2之action跳转到别的action同时传递参数

2018-03-06 16:09 330 查看
struts2 的action跳转到别的action时,可以使用redirectAction

如:

<action name="hr_emp" class="hrEmployeeAction">
<result name="loginForCustomer" type="redirectAction">./pages_crm/crm_cust</result>
</action>

如果还需要传递参数:

可以这样:
<action name="hr_emp" class="hrEmployeeAction">
<result name="loginForCustomer" type="redirectAction">
   <param name="actionName">./pages_crm/crm_cust</param>

                                   <param name="bwvobj.id">${customerId}</param>
</result>
</action>

在hrEmployeeAction中设置customerId属性,并有set和get方法。
public class HrEmployeeAction extends ActionSupport{

private String customerId;

public String getCustomerId() {
return customerId;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
}
.....

}

这样就可以通过struts2的action跳转到别的action。同时传递参数过去。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: