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

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

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

      2. 如何在 Struts 2 中的一个表单上添加两个提交按钮

        时间:2023-10-15
      3. <tfoot id='Jb8iP'></tfoot>

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

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

                  <bdo id='Jb8iP'></bdo><ul id='Jb8iP'></ul>
                • 本文介绍了如何在 Struts 2 中的一个表单上添加两个提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Struts2 开发应用程序.我的申请是网上购物.我的任务是更新和删除购物车项目.我有一个 JSP 页面,它有 4 个文本字段.我需要将这些文本字段的数据提交给 Modify 操作.更新和删除提交按钮在同一个页面,相同的形式.如何确定我在 JSP 表单上单击了哪个按钮?

                  I'm developing an application using Struts2. My application is for online shopping. My task is updating and removing the shopping cart item. I have a JSP page and it has 4 text fields. I need to submit these text field's data to the Modify action. Updating and removing submit buttons are in same page, same form. How do I determine which is the button I've clicked on JSP form?

                  我的表格是:

                  <s:form action="ModifyCart">
                     <s:textfield readonly="true" name="shoppingCart.item.id" label="Item Code" value="% item.id}"/>
                     <s:textfield readonly="true" label="Item Name" value="%{item.itemName}"/>
                     <s:textfield name="shoppingCart.qty" value="%{qty}"/>                                                                
                     <s:textfield readonly="true" label="Available Quantity" name="shoppingCart.item.qty" value="%{item.qty}"/>
                     <s:submit type="button" label="Update" name="submit"/>
                     <s:submit type="button" label="Remove" name="clear"/></s:form>
                  

                  重要:

                  我需要在每次提交时将所有文本字段的数据提交到 Action 类.

                  I need to submit all text field's data to the Action class with every submit.

                  推荐答案

                  struts2如何在一个表单中添加2个提交按钮

                  How to add 2 submit buttons in one form in struts2

                  好像你已经完成了,type="button" 意味着一个 button type="submit" 是通过 Struts 标签生成的,但是你可以使用 type="submit.对于 description 你可以参考文档.它们之间没有太大区别,因为它们中的任何一个都提交表单.如果你想执行不同的动作或动作类的方法,那么你可以使用额外的属性,如 actionsubmit 标签中的 method.

                  Seems you have already done it, type="button" means a button type="submit" is generated via the Struts tag, but you could use type="submit. For description you can refer the documentation. Not much difference between them, because any of them submit the form. If you want to execute different action or method of the action class then you could use additional attributes like action or method in the submit tag.

                  如何判断jsp表单上点击的是哪个按钮

                  How do I determine which is the button I've clicked on jsp form

                  这取决于您想在客户端或服务器端的哪个位置执行此操作,或两者兼而有之.在客户端,您可以使用 javascript 来处理表单或按钮本身的事件.代码由不同的处理程序分隔,因此在处理程序中您确切知道触发事件的元素,或使用对象 target 属性来确定类似于 这个答案.在服务器端,您可以使用 inputbutton 标记的 value 属性,该属性由 name 生成并作为参数传递.请注意,并非所有 HTML 浏览器都使用按钮 value 属性.

                  It depends on where do you want to do it on the client side or on the server side, or both. On the client side you can use javascript to handle events of the form or the button itself. The code is separated by the different handler, so in the handler you exactly know the element that triggered the event, or use an object target attribute to determine that like in this answer. On the server side you can use a value attribute of the input or button tag that is generated and passed as a parameter by name. Note, not all HTML browsers work with the button value attribute.

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

                • <legend id='5hgAT'><style id='5hgAT'><dir id='5hgAT'><q id='5hgAT'></q></dir></style></legend>
                • <small id='5hgAT'></small><noframes id='5hgAT'>

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

                      <tbody id='5hgAT'></tbody>
                      <bdo id='5hgAT'></bdo><ul id='5hgAT'></ul>