struts2 action间跳转传值
2010-08-27 13:39
225 查看
(方法一):
我现在需要把一个action(action1)中的变量传递到另外的一个action(action2)中,两个action中都定义了属性
String userId,User
user,并且定义了相应的getter,setter方法,在struts.xml中配置如下:
<action name="action1" class="Action1">
<result name="toLiginIndex" type="redirectAction" >
<param name="actionName">Action2</param>
<param name="namespace">/</param> 同一个namespace时可以不写
<param name="user">${user}</param>
<param name="userId">${userId}</param>
</result>
<result name="notLogIn">/index_notLogin.jsp</result>
</action>
这时跳转成功,但是ognl会抛出异常,因为没有flag的set方法
(方法二)
<result name="toLiginIndex" type="chain">
<param name="actionName">Action2</param>
</result>
这时action1的参数就都传到Action2了,Action2没有要Action1传递的参数的声明也可以在页面中显示出参数的值
(方法三)
<result name="topic"
type="redirect">/topicAction!findTopics.do?topicId=${topicId}</result>
我现在需要把一个action(action1)中的变量传递到另外的一个action(action2)中,两个action中都定义了属性
String userId,User
user,并且定义了相应的getter,setter方法,在struts.xml中配置如下:
<action name="action1" class="Action1">
<result name="toLiginIndex" type="redirectAction" >
<param name="actionName">Action2</param>
<param name="namespace">/</param> 同一个namespace时可以不写
<param name="user">${user}</param>
<param name="userId">${userId}</param>
</result>
<result name="notLogIn">/index_notLogin.jsp</result>
</action>
这时跳转成功,但是ognl会抛出异常,因为没有flag的set方法
(方法二)
<result name="toLiginIndex" type="chain">
<param name="actionName">Action2</param>
</result>
这时action1的参数就都传到Action2了,Action2没有要Action1传递的参数的声明也可以在页面中显示出参数的值
(方法三)
<result name="topic"
type="redirect">/topicAction!findTopics.do?topicId=${topicId}</result>
相关文章推荐
- struts2 action间跳转传值
- struts2 action间跳转传值
- struts2-action间跳转及间传值
- Struts2 action之间传值与跳转
- struts2声明式验证input视图跳转到另外一个action后错误提示不显示解决办法
- struts2 action 之间跳转
- struts2 跳转类型 result type=chain、dispatcher、redirect(redirect-action)
- struts2 Action获取表单传值(属性,类))
- Struts2第三篇【Action开发方式、通配符、Struts常量、跳转全局视图、action节点默认配置】
- Struts2 action的跳转类型
- struts2 从一个action 跳转到另一个action的两种方法
- 3种方法解决Struts2中forward问题!通过jsp:forward跳转到WEB-INF 下的action中
- 【struts2】action里result到action之间的跳转、不同包package
- struts2使用注解配置Action之间的跳转
- struts2中jsp页面传值到action的两种方式
- STRUTS2 ACTION的跳转类型说明
- 关于Struts2使用redirectAction方式在两个Action之间传值时中文乱码问题的解决方法
- struts2 从一个action 跳转到另一个action的两种方法
- Struts2 action跳转及重复执行
- struts2使用action跳转后的页面路径如果是相对路径的话会出现css、js以及图片等无法加载问题