Struts2之两个Action传值和不传值的struts.xml文件配置
2011-07-28 12:31
555 查看
例如 在执行完action1之后要直接跳转到action2,并且action1要传一些参数给action2,在struts.xml文件中的配置如下:
<action name="action1" method="">
<result name="success" type="chain">
<param name="actionName">action2</param>
<param name="param1">${param1}</param>
<param name="param2">${param2}</param>
</result>
</action> 注意:
1. 若param1和param2是两个变量,那么在两个action中都要有他们的getter和setter
2. 若param1是常量,那么在action1中只要有一个param1的getter,在action2中要有param1的getter和setter 如果在两个action之间直接跳转而不用传参数,struts.xml文件可以和上面一样,只是没有param标签,还可以使用如下配置:
<action name="action1" method="">
<result name="success" type="redirectAction">action2.action</result>
</action>
即可
<action name="action1" method="">
<result name="success" type="chain">
<param name="actionName">action2</param>
<param name="param1">${param1}</param>
<param name="param2">${param2}</param>
</result>
</action> 注意:
1. 若param1和param2是两个变量,那么在两个action中都要有他们的getter和setter
2. 若param1是常量,那么在action1中只要有一个param1的getter,在action2中要有param1的getter和setter 如果在两个action之间直接跳转而不用传参数,struts.xml文件可以和上面一样,只是没有param标签,还可以使用如下配置:
<action name="action1" method="">
<result name="success" type="redirectAction">action2.action</result>
</action>
即可
相关文章推荐
- Struts2之两个Action传值和不传值的struts.xml文件配置
- Struts2之两个Action传值和不传值的struts.xml文件配置
- Struts2之两个Action传值和不传值的struts.xml文件配置
- struts2的配置之could not find action or result 问题的解决方法(struts.xml文件路径)
- struts2 两个action方法的跳转 struts.xml怎么配置
- struts2 从一个action跳转到另一个action的struts.xml文件的配置
- Struts2 两个Action 动态传参数,在struts.xml中配置
- [Struts2]配置之Result/include多配置struts.xml文件/Action
- Struts2中struts.xml的Action配置详解
- Struts2学习笔记之struts.xml配置常量和Action处理流程
- Struts2.0 xml文件的配置(package,namespace,action)
- Struts2中struts.xml的Action配置详解
- Struts2中struts.xml的Action配置详解
- Struts2-action在struts.xml中的配置
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- struts2之Action配置的各项默认值、result配置的各种试图转发类型及为应用指定多个struts配置文件
- 【Struts2文件下载】struts.xml文件中配置action,访问路径问题
- 【转】Struts2.0 xml文件的配置(package,namespace,action) 留着用
- Struts2中,action配置文件中两个action带参数的调用
- Struts常量 Struts2 action 定义 配置 操作内置对象