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

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

    <tfoot id='BSZNs'></tfoot>

        Struts 2 表单标签中的多个提交按钮

        Multiple submit buttons in Struts 2 form tag(Struts 2 表单标签中的多个提交按钮)
            <bdo id='1lLjg'></bdo><ul id='1lLjg'></ul>

            <small id='1lLjg'></small><noframes id='1lLjg'>

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

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

                  <legend id='1lLjg'><style id='1lLjg'><dir id='1lLjg'><q id='1lLjg'></q></dir></style></legend>

                2. 本文介绍了Struts 2 表单标签中的多个提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图将表单标签中的按钮指向与表单不同的动作/动作类,但它不起作用.我在另一个线程中读到这是由于 Struts 2 中的一个错误,应该设置 struts.mapper.action.prefix.enabled"="true",所以我做到了,但它仍然是一样的.

                  I'm trying to point a button in my form tag to a different action/action class than the form but it won't work. I read in another thread that this is due to a bug in Struts 2 and that struts.mapper.action.prefix.enabled"="true" should be set, so I did it but it's still the same.

                  我可以使用不同的动作指向表单正在使用的同一动作类的不同方法,但是当我尝试指定不同的动作类时它不起作用.

                  I can use a different action pointing to a different method of the same action class that the form is using but when I try specifying a different action class it doesn't work.

                  这行得通,

                  (jsp)

                  <s:form action="print">     
                      <s:iterator value="itemList">
                          <s:radio theme="simple" name="item" list="#{id:name}" />
                      </s:iterator>
                  
                      <div id="functionButtons">
                          <s:submit key="button.submit" />
                          <s:submit action="cancel" key="button.cancel"/>
                      </div>
                  
                  </s:form>
                  

                  (struts.xml)

                  <constant name="struts.mapper.action.prefix.enabled" value="true" />
                  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
                  
                                       ...
                  
                  <action name="print" class="...PrintItem" method="perform" > 
                      <result name="success">/successJSP.jsp</result>
                  </action>
                  
                  <action name="cancel" class="...PrintItem" method="cancel" > 
                      <result name="CANCEL" type="redirectAction">homePage</result>
                  </action>
                  

                  (动作)

                  public class PrintItem extends BaseAction {
                  
                      @Override
                      public String perform() throws Exception {
                  
                          doPrintLogic();
                          return SUCCESS;
                  
                      }
                  
                      public String cancel(){
                  
                          return "CANCEL";
                  
                      }
                  }
                  

                  但如果我将 struts.xml 中的取消"动作映射更改为

                  but if I change "cancel" action mapping in struts.xml to

                  <action name="cancel" class="...CancelFormAction" method="perform" > 
                      <result name="CANCEL" type="redirectAction">trnsfr</result>
                  </action>
                  

                  没有

                  这正常吗?是否可以从已经映射到一个表单的表单中映射到不同的操作类?

                  Is that normal? Is it possible to map to a different action class from within a form that's already mapped to one?

                  推荐答案

                  这是正常的,因为您只能将表单映射到由表单标签的 action 属性指定的一个动作(在 HTML 中是历史性的).提交按钮不会更改该映射,而是会调整动作映射器以使用不同的动作,因为启用了前缀.因此,如果您需要更改此行为,您可以动态更改表单映射或更改默认操作映射器等.但是,如果操作实例已经创建,则会出现问题.因此,您应该使用默认操作映射器.但是您的帖子 struts.mapper.action.prefix.enabled"="true" 中有一个错字.启用提交按钮操作的常量是

                  This is normal, because you can map the form to only one action specified by the action attribute of the form tag (Historically in HTML). Submit buttons don't change that mapping, instead they tweak an action mapper to use different action because the prefix is enabled. So, if you need to change this behavior you can alter form mapping dynamically or change the default action mapper, etc. However, it would be a problem if the action instance is already created. Hence, you should use default action mapper. But there's a typo in your post struts.mapper.action.prefix.enabled"="true". The constant that enables action on submit buttons is

                  <constant name="struts.mapper.action.prefix.enabled" value="true"/>
                  

                  或者如果你使用 struts.properties

                  struts.mapper.action.prefix.enabled=true
                  

                  这篇关于Struts 2 表单标签中的多个提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  <legend id='uLqG5'><style id='uLqG5'><dir id='uLqG5'><q id='uLqG5'></q></dir></style></legend>

                      <tbody id='uLqG5'></tbody>

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

                        • <bdo id='uLqG5'></bdo><ul id='uLqG5'></ul>
                          1. <tfoot id='uLqG5'></tfoot>

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