<tfoot id='uHQQb'></tfoot>
  • <small id='uHQQb'></small><noframes id='uHQQb'>

      <i id='uHQQb'><tr id='uHQQb'><dt id='uHQQb'><q id='uHQQb'><span id='uHQQb'><b id='uHQQb'><form id='uHQQb'><ins id='uHQQb'></ins><ul id='uHQQb'></ul><sub id='uHQQb'></sub></form><legend id='uHQQb'></legend><bdo id='uHQQb'><pre id='uHQQb'><center id='uHQQb'></center></pre></bdo></b><th id='uHQQb'></th></span></q></dt></tr></i><div id='uHQQb'><tfoot id='uHQQb'></tfoot><dl id='uHQQb'><fieldset id='uHQQb'></fieldset></dl></div>
      <legend id='uHQQb'><style id='uHQQb'><dir id='uHQQb'><q id='uHQQb'></q></dir></style></legend>

        <bdo id='uHQQb'></bdo><ul id='uHQQb'></ul>
      1. Struts 2:Action之间的参数

        时间:2023-09-25
      2. <i id='Kuhfz'><tr id='Kuhfz'><dt id='Kuhfz'><q id='Kuhfz'><span id='Kuhfz'><b id='Kuhfz'><form id='Kuhfz'><ins id='Kuhfz'></ins><ul id='Kuhfz'></ul><sub id='Kuhfz'></sub></form><legend id='Kuhfz'></legend><bdo id='Kuhfz'><pre id='Kuhfz'><center id='Kuhfz'></center></pre></bdo></b><th id='Kuhfz'></th></span></q></dt></tr></i><div id='Kuhfz'><tfoot id='Kuhfz'></tfoot><dl id='Kuhfz'><fieldset id='Kuhfz'></fieldset></dl></div>

        <tfoot id='Kuhfz'></tfoot><legend id='Kuhfz'><style id='Kuhfz'><dir id='Kuhfz'><q id='Kuhfz'></q></dir></style></legend>

          <small id='Kuhfz'></small><noframes id='Kuhfz'>

              <tbody id='Kuhfz'></tbody>
              • <bdo id='Kuhfz'></bdo><ul id='Kuhfz'></ul>

                  本文介绍了Struts 2:Action之间的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下问题:当我完成一个表单并且操作保存表单的值时,我需要传递一个参数(例如 ID ),这将转发到 result = "success" 并且我需要成功调用的操作附带ID 和其他参数稍后在下一个表单中用于保存此信息(info-form2 和 info.form1)...

                  I have the following question: I need to pass a parameter (for example ID ) when I finish a form and the action save the form's values, this will forward to the result = "success" and I need that the action that will be call in the success come with the ID and other parameters to later use in the next form for save this information (info-form2 and info.form1)...

                  例如:

                  FORM1(用户)====成功"====> FORM2(地址)

                  userForm.html ===================> addressForm.html?user_id=X ...(其中 X : Id 传递了 UserAction (方法:save) 到 AddressAction (method:newAddress))

                  感谢您的帮助

                  提前致谢

                  推荐答案

                  您使用了转发"一词,但听起来您想转到新页面(address.html)以收集有关该地址的更多信息.如果是这种情况,您需要在用户操作完成后重定向到地址页面.

                  You used the word "forward" but it sounds like you want to go to a new page (address.html) to collect more information about the address. If this is the case, you need to redirect to the address page after the user action completes.

                  <action name="user" class="UserAction">
                    <!-- Redirect to another namespace -->
                    <!-- for Struts 2.2 --> <result type="redirectAction">
                    <!-- for Struts 2.0 <result type="redirect-action"> -->
                      <param name="actionName">collect-address</param>
                      <param name="userId">${userId}</param>
                    </result>
                  </action>
                  

                  ${userId} 语法将在您的 UserAction 上调用 getUserId 并传递您在问题中显示的该参数:addressForm.html?user_id=X.collect-address 可以将成功结果发送到 addressForm.html.Docs here. 如果您想避免使用其他操作,您可以尝试 使用结果 type="redirect" 和通过这种方式传递东西.

                  The ${userId} syntax will call getUserId on your UserAction and pass that parameter as you showed in your question: addressForm.html?user_id=X. collect-address can have a success result that goes to addressForm.html. Docs here. If you want to avoid using another action, you can try using the result type="redirect" and pass things through that way.

                  如果真的要转发,可以使用action chaining.Struts2 团队的 Ted Husted 不鼓励这样做,但是它可能对你有用.

                  If you really want to forward, you can use action chaining. This is discouraged by Ted Husted on the Struts2 team but it may work for you.

                  尝试将完成此请求的所有代码放入单个操作中,并使用 User 和 Address 的帮助器或服务类来分离和重用代码,而不是操作链接".

                  Instead of action chaining, try to bring all the code to complete this request into a single action and use helper or service classes for User and Address to separate and reuse the code instead of "action chaining".

                  这篇关于Struts 2:Action之间的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Struts2 线程中的拦截器不安全吗? 下一篇:如何从 jsp 将日期输入到 Struts2 动作?

                  相关文章

                  <legend id='o3QjX'><style id='o3QjX'><dir id='o3QjX'><q id='o3QjX'></q></dir></style></legend>

                  <small id='o3QjX'></small><noframes id='o3QjX'>

                    • <bdo id='o3QjX'></bdo><ul id='o3QjX'></ul>
                    <i id='o3QjX'><tr id='o3QjX'><dt id='o3QjX'><q id='o3QjX'><span id='o3QjX'><b id='o3QjX'><form id='o3QjX'><ins id='o3QjX'></ins><ul id='o3QjX'></ul><sub id='o3QjX'></sub></form><legend id='o3QjX'></legend><bdo id='o3QjX'><pre id='o3QjX'><center id='o3QjX'></center></pre></bdo></b><th id='o3QjX'></th></span></q></dt></tr></i><div id='o3QjX'><tfoot id='o3QjX'></tfoot><dl id='o3QjX'><fieldset id='o3QjX'></fieldset></dl></div>

                    1. <tfoot id='o3QjX'></tfoot>