title: spring mvc annotation validation integer
body: <p>I have an object.</p>
  
  <pre><code>public class MyObject
  {
     ....
     @Column(name = "a_number") @NotNull @NumberFormat(style = Style.NUMBER) @Min(1)
     private Integer aNumber;
     ...
     //getters and setters
  }
  </code></pre>
  
  <p>In my controller I have @Valid annotation on my object being posted. I do have validation working on all my other fields in the class (their all Strings) except this number.  If I enter a number from my form it works fine and if I violate the @Min(1) it also gives me the correct validation error.  My problem however is that if you enter a string instead of a number it throw a NumberFormatException.</p>
  
  <p>I've seen many examples of Integer and validation but no one accounts for if you enter a string into the form being posted.  Do I need to do the validation else where? Javascript?  I would like a solution that falls in line with the rest of spring validation so I could use this in other classes.  I would just like an error stating it must be numeric.  Also I tried using the @Pattern annotation but apparently thats just for strings.</p>
  
  <p>Suggestions?</p>