zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    html css 学习
    第七天
    第六天
    第五天
    第四天
    第三天
    第二天
    团队敏捷开发day8
    团队敏捷开发day7
    团队敏捷开发day6
  • 原文地址:https://www.cnblogs.com/toge/p/6114694.html
Copyright © 2011-2022 走看看