Struts2 Multiple Submit Buttons


In this example, we will see how to use multiple submit buttons within a single form to call multiple methods in the same action.


1. Technologies used

  • Struts 2.3.16
  • Maven 3.0.5
  • Eclipse 4.4
  • JDK 1.6
  • Tomcat 6.0


2. Project structure



3. Action class

The action methods return the name of JSP page to show in the browser.

File : UserAction


4. JSP form

File : index.jsp


We have used a single form and 4 submit buttons, each submit calls one of the methods defined in the action class.

The first submit calls the default execute() method.


5. Struts config

We need to set the struts.enable.DynamicMethodInvocation constant to true

File : struts.xml


6. Test It

URL : http://localhost:8080/Struts2MultipleSubmitButtons/user/index.action



Download source code