I have 3 buttons for a form I would like to submit. I’m new to struts and I was wondering, is there a way to find which button was clicked? In my html I have this
<html:form action="myAction.jspa">
<div align="right">
<html:submit value="back" />
<html:submit value="continue Later" />
<html:submit value="submit" />
</div>
</html:form>
And in my Java Action class in the execute() method, I attempt using request.getParameter("back") to check if the back button has been pressed but it doesn’t work. How does one handle multiple submit buttons in struts?
Thanks for help in advance 🙂
Use the
propertyattribute on your<html:submit>tag to specify the name of the request parameter that you’ll check in your action.JSP
Action
You can, alternatively, give all of your submit buttons the same property, then check the value of the parameter in your action. However, that adds additional internationalization concerns (you’d need to check for non-English translations of the same string).
For more information, see the Struts API.