title: Struts2: method attribute in <s:submit> button doesn't work
body: <p>I have a form in jsp. There are two submit buttons: "Search" and "Add New" button. I had set each button with their own method attribute.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;s:form name="searchForm" action="employeeAction" method="post"&gt;
      &lt;s:textfield name="id" label="Employee ID"/&gt;
      &lt;s:textfield name="name" label="Employee Name"/&gt;
  
      &lt;s:submit value="Search" method="doSearch"/&gt;
      &lt;s:submit value="Add New" method="doAddNew"/&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>In struts.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
      "http://struts.apache.org/dtds/struts-2.3.dtd"&gt;
  
  &lt;struts&gt;
  
      &lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&gt;
      &lt;constant name="struts.devMode" value="true" /&gt;
  
      &lt;package name="default" namespace="/" extends="struts-default"&gt;
  
          &lt;default-action-ref name="index" /&gt;
  
          &lt;global-results&gt;
              &lt;result name="error"&gt;/error.jsp&lt;/result&gt;
          &lt;/global-results&gt;
  
          &lt;global-exception-mappings&gt;
              &lt;exception-mapping exception="java.lang.Exception" result="error"/&gt;
          &lt;/global-exception-mappings&gt;
  
      &lt;/package&gt;
  
      &lt;package name="example" namespace="/example" extends="default"&gt;
  
          &lt;action name="employeeAction" class="example.EmployeeAction"&gt;
             &lt;result name="search"&gt;/example/search.jsp&lt;/result&gt;
             &lt;result name="add"&gt;/example/add.jsp&lt;/result&gt;
          &lt;/action&gt;
  
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  
  <p>In EmployeeAction class</p>
  
  <pre><code>public class EmployeeAction extends ActionSupport {
  
      private static final Logger logger = Logger.getLogger(EmployeeAction.class);
  
      @Override
      public String execute() throws Exception {    
          logger.info("Calling execute!");    
          return SUCCESS;
      }
  
      public String doSearch() throws Exception {    
          logger.info("Calling doSearch!");    
          return "search";
      }
  
      public String doAddNew() throws Exception {    
          logger.info("Calling doAddNew!");    
          return "add";
      }
  }
  </code></pre>
  
  <p>The problem is when I clicked <strong>"Search"</strong> or <strong>"Add New"</strong> button, the method <strong>doSearch()</strong> or <strong>doAddNew()</strong> was never called, instead it called method <strong>execute()</strong>. What is wrong with my code above?</p>
  
  <p>I'm using struts v2.3.</p>