title: spring 3.0 MVC seems to be ignoring messages.properties
body: <p>Spring 3.0 MVC</p>
  
  <p>First of all, I haven't found any documentation regarding messages.properties @ <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/" rel="nofollow noreferrer">springsource</a>  Everything I've found about overriding error messages has been on various forums.  If anyone has a reference to where messages.properties is documented that'd be fantastic.  Maybe messages.properties comes not from spring but a java spec?</p>
  
  <p>I have tried following the advice on
  <a href="https://stackoverflow.com/questions/4082924/jsr-303-type-checking-before-binding/4083198#4083198">JSR-303 Type Checking Before Binding</a> My goal is to replace some type mismatch error messages with my own user friendly error messages</p>
  
  <p>My situation is as follows:</p>
  
  <p>Model</p>
  
  <pre><code>public class Test {
  
      private int numberbomb;
  
      public int getNumberbomb() {
          return numberbomb;
      }
  
      public void setNumberbomb(int numberbomb) {
          this.numberbomb = numberbomb;
      }
  }
  </code></pre>
  
  <p>myservlet.xml</p>
  
  <pre><code>&lt;mvc:annotation-driven/&gt;
  </code></pre>
  
  <p>jsp</p>
  
  <pre><code>&lt;form:form id="test" method="post" modelAttribute="test"&gt;
  
  &lt;form:errors path="*"/&gt;
  
  &lt;form:label path="numberbomb"&gt;numberbomb&lt;/form:label&gt;
  &lt;form:input path="numberbomb"/&gt;
  
  &lt;/form:form&gt;
  </code></pre>
  
  <p>classes\messages.properties</p>
  
  <pre><code>typeMismatch=bad value you bad bad person
  test.numberbomb=you are driving me crazy with these bad inputs
  </code></pre>
  
  <p>Output from the form</p>
  
  <blockquote>
    <p>Failed to convert property value of type java.lang.String to required type int for property numberbomb; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "three" from type java.lang.String to type int; nested exception is java.lang.NumberFormatException: For input string: "three"</p>
  </blockquote>
  
  <p>BindingResult.toString() within my controller</p>
  
  <blockquote>
    <p>Field error in object 'test' on field 'numberbomb': rejected value [three]; codes [typeMismatch.test.numberbomb,typeMismatch.numberbomb,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [test.numberbomb,numberbomb]; arguments []; default message [numberbomb]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'numberbomb'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "three" from type 'java.lang.String' to type 'int'; nested exception is java.lang.NumberFormatException: For input string: "three"]</p>
  </blockquote>
  
  <p>Is displaying the error messages with <code>&lt;form:errors&gt;</code> the wrong way display custom error messages?  Do I need to add something to spring config files to tell it to look at messages.properties?  Spring seems to be ignoring my messages.properties file (which is located in the WEB-INF\classes folder)</p>
  
  <p>Thanks for any ideas!</p>