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
How to add 2 submit buttons in one form in struts2
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.
How do I determine which is the button I've clicked on jsp form
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.