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

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

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

  • <tfoot id='B2DBZ'></tfoot>

        如何在不提交表单的情况下使用struts2提交标签作为按钮?

        How to use struts2 submit tag as button without submitting the form?(如何在不提交表单的情况下使用struts2提交标签作为按钮?)
        <legend id='nWqk1'><style id='nWqk1'><dir id='nWqk1'><q id='nWqk1'></q></dir></style></legend>
        <tfoot id='nWqk1'></tfoot>
          <tbody id='nWqk1'></tbody>
        • <bdo id='nWqk1'></bdo><ul id='nWqk1'></ul>

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

                • <small id='nWqk1'></small><noframes id='nWqk1'>

                • 本文介绍了如何在不提交表单的情况下使用struts2提交标签作为按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的应用程序中使用 Struts2 框架,我的 JSP 页面上有一个按钮.那是

                  I am using Struts2 framework in my application, I have one button on my JSP page. That is

                  <s:submit type="button" name="btnSave" />
                  

                  现在,我希望这个按钮表现得像普通的 HTML 按钮类型不应该提交表单并执行脚本onclick 事件的函数.该函数使用 Ajax 提交表单.

                  Now, I want this button to behave as normal HTML button type should not submit the form and execute the Scripting function on onclick event. That function submit the form using Ajax.

                  但是发生的事情是 Struts2 将其转换为

                  But what happens is Struts2 convert it to

                  <input type="submit" id="add_btnSave" name="btnSave" value="Save"/>
                  

                  我的表单已提交.

                  1) 如果我使用 HTML 按钮标签,它会弄乱 GUI.我表单的主题是 Ajax.

                  1) If I use the HTML button tag it will mess the GUI. As theme of my form is Ajax.

                  这是一个带有脚本的head标签

                  This is a head tag with script

                  <head>
                  <s:head theme="ajax"/>
                  <script type="text/javascript">
                  
                  $("btnSave").click(function(){
                  alert("aaa");
                  $.ajax({
                  url:
                  type:"POST",
                  dataType: "json",
                  error: function(XMLHttpRequest, textStatus, errorThrown){
                  alert('Error ' + textStatus);
                  alert(errorThrown);
                  alert(XMLHttpRequest.responseText);
                  },
                  success: function(){
                  alert('SUCCESS');
                  }
                  });
                  });
                  </script>
                  </head>
                  

                  我的 body 标签是关注者:

                  My body tag is as followers :

                  <body>
                  <table border="1" width="80%" align="center">
                  <tr>
                  <td width="100%">
                  <s:tabbedPanel id="EmpDetail" useSelectedTabCookie="true">
                  <s:div id="one" label="Emp Reg." theme="ajax" tabindex="0" labelposition="top">
                  <center>
                  <s:form name="frmEmpReg" namespace="/" method="post">
                  EMPLOYEE REGISTRATIOM TAB<br>
                  <s:actionmessage />
                  <input type="hidden" name="empbean.id" value="<s:property value="empbean.id"/>"/>
                  <s:textfield label="Employee First Name" name="empbean.firstName"></s:textfield>
                  <s:textfield label="Employee Middle Name" name="empbean.middleName"></s:textfield>
                  <s:textfield label="Employee Last Name" name="empbean.lastName"></s:textfield>
                  <s:textfield label="Address" name="empbean.address"></s:textfield>
                  <s:textfield label="State" name="empbean.state"></s:textfield>
                  <s:textfield label="Employee Designation" name="empbean.designation"></s:textfield>
                  <s:submit name="btnSave" type="submit" value="Save" align="center"/>
                  </s:form>
                  </center>
                  </s:div>
                  <s:div>
                  ..
                  ..
                  Other Tabs
                  </s:div>
                  </s:tabbedPanel>
                  </td>
                  </tr>
                  </table>
                  </body>
                  

                  任何人都知道如何使用 Struts2 处理它,那么请帮忙.

                  any one have any idea of handling it with Struts2 then please help.

                  非常感谢您的帮助.

                  推荐答案

                  如果你使用 s:submit 标签,渲染的 HTML 输出是 inputbutton 标签,但类型是 submit 除了 image 类型.您可以使用代码执行不提交表单的javascript onclick事件.

                  If you are using s:submit tag the rendered HTML output is either input or button tag but the type is submit except for the image type. You can use the code to execute javascript onclick event that doesn't submit the form.

                  <s:submit type="button" onclick="return false;"/>
                  

                  这篇关于如何在不提交表单的情况下使用struts2提交标签作为按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                    <tbody id='s9bRx'></tbody>
                  <i id='s9bRx'><tr id='s9bRx'><dt id='s9bRx'><q id='s9bRx'><span id='s9bRx'><b id='s9bRx'><form id='s9bRx'><ins id='s9bRx'></ins><ul id='s9bRx'></ul><sub id='s9bRx'></sub></form><legend id='s9bRx'></legend><bdo id='s9bRx'><pre id='s9bRx'><center id='s9bRx'></center></pre></bdo></b><th id='s9bRx'></th></span></q></dt></tr></i><div id='s9bRx'><tfoot id='s9bRx'></tfoot><dl id='s9bRx'><fieldset id='s9bRx'></fieldset></dl></div>

                      <tfoot id='s9bRx'></tfoot>
                      • <bdo id='s9bRx'></bdo><ul id='s9bRx'></ul>

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

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