struts2 action间跳转传值

(方法一):
我现在需要把一个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>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值