title: Form validation in Struts2
body: <p>Page contains form which looks like below. </p>
  
  <p>1) If I insert to form <em>validate="true"</em>, then after page load this form submit request to mail action (at this point validation xml was not created yet).</p>
  
  <p>2) After validation xml was created (in the same pakage with action), then action which control request to this page returns 404 page.</p>
  
  <p>Did I miss something?</p>
  
  <pre><code>&lt;s:form action="mail" method="post"&gt;
  &lt;s:textfield name="name" key="Your name" size="20" /&gt;   
  &lt;div style="clear: both;margin-top:10px"&gt;&lt;/div&gt;
  &lt;s:textarea label="Comment" name="comment" cols="65" rows="5"/&gt;
  &lt;s:submit method="mail" key="Send" align="left" 
      style="width:100px; height:35px; margin-top:20px"/&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>validation xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
      "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"&gt;
  &lt;validators&gt;
      &lt;field name="name"&gt;
          &lt;field-validator type="required"&gt;
              &lt;message&gt;Please enter a user name&lt;/message&gt;
          &lt;/field-validator&gt;
      &lt;/field&gt;
      &lt;field name="comment"&gt;
          &lt;field-validator type="required"&gt;
              &lt;message&gt;Please enter your message&lt;/message&gt;
          &lt;/field-validator&gt;
      &lt;/field&gt;
  &lt;/validators&gt;
  </code></pre>
  
  <p>If I do not add validation then all is working as it should.</p>
  
  <p>struts.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
    &lt;constant name="struts.devMode" value="true" /&gt;
  
    &lt;constant name="struts.custom.i18n.resources" value="ApplicationResources" /&gt;
  
    &lt;package name="default" namespace="/" extends="struts-default"&gt;
  
          &lt;global-results&gt;
              &lt;result name="Exception"&gt;/error404.jsp&lt;/result&gt;
          &lt;/global-results&gt;
  
          &lt;global-exception-mappings&gt;
              &lt;exception-mapping exception="java.lang.Throwable" result="Exception" /&gt;
          &lt;/global-exception-mappings&gt;
  
          &lt;!-- loads page --&gt;
          &lt;action name="main" 
              class="com.user.action.LoginAction" method="main"&gt;
              &lt;result name="success"&gt;/main.jsp&lt;/result&gt;
          &lt;/action&gt;
  
          &lt;!-- mail action --&gt;
          &lt;action name="mail" class="com.user.action.LoginAction" method="mail" &gt;
              &lt;result name="success"&gt;/main.jsp&lt;/result&gt;
          &lt;/action&gt;       
  
    &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>