日期:2014-05-20  浏览次数:20781 次

structs2配置文件中返回success成功后,怎么让重定向的文件是可变的???
例如:
<action name="bookSave" class="com.gtjy.sitemanager.action.ProductAction" method="saveProduct">
<result name="success" type="chain">bookAdd?typeid=912</result>  
<result name="error">error.jsp</result>  
</action>
我这里想把bookAdd?typeid=912做成变量
现在如果是bookAdd后面不带typeid我可以实现
就是在action里定义个retpage变量,有set和get方法,然后在retpage="bookAdd"
<result name="success" type="chain">${bookAdd}</result>是可以的,如果retpage="bookAdd?typeid=912"这样就不对
或是<result name="success" type="chain">${bookAdd}?typeid=912</result>这样也不对,这问题怎么解决呀,谁知道,求救

------解决方案--------------------
xid 是ProductAction类的成员。

<result name="success" type="chain">bookAdd?typeid=${xid}</result>
------解决方案--------------------
在两个action里设置两个同名的 变量,配上set get方法
action传递执行的时候会自动吧同名变量传递下去的。

如:
action1 中有个私有变量private int xxx 有get set
给他赋值 
xxx = 111;
return SUCCESS;

 <result name="success" type="chain">action2</result> 



action2 中也有个私有变量 private int xxx 有get set 方法

System.out.println("xxx");
得到的结果就是 111