title: Spring MVC: Failed to convert property value of type String to Integer
body: <p>My code looks like this</p>
  
  <pre><code>@RequestMapping(value = "/test2Form", method = RequestMethod.POST)
  public String testForm(@ModelAttribute("someBean") SomeBean someBean, BindingResult result) {
      BindException errors = new BindException(someBean, "someBean");
      someValidator.validate(someBean, errors);
  
      for (FieldError error : errors.getFieldErrors()) {
          result.addError(new FieldError("someBean", error.getField(), error.getCode()));
      }
  
      // Field error
      if (result.hasErrors()) {
          return "test/test1";
      }
  
      return "index";
  }
  
  public class SomeBean{
      private Integer someInteger;
      // getter and setter
  }
  </code></pre>
  
  <p>This works fine until the user changes the value via HTML to a non Integer value, e.g. like this: <a href="http://www.pichost.de/image/9IN" rel="nofollow">http://www.pichost.de/image/9IN</a></p>
  
  <p>In this case a type mismatch occurs (something like <code>Failed to convert property value of type java.lang.String to required type java.lang.Integer for property someInteger; nested exception is java.lang.NumberFormatException</code>). 
  I don't want to display this generated error message. Instead, I want to display only my error messages. Is this possible?</p>
  
  <p>My JSP looks like this:</p>
  
  <pre><code>&lt;form:form action="test2Form.htm" commandName="someBean" method="post"&gt;
      &lt;form:select path="someInteger"&gt;
          &lt;option value="1"&gt;Value 1&lt;/option&gt;
          &lt;option value="2"&gt;Value 2&lt;/option&gt;
          &lt;option value="3"&gt;Value 3&lt;/option&gt;
      &lt;/form:select&gt;
      &lt;form:errors path="someInteger" element="div"/&gt;
  
      &lt;input type="submit" value="Submit"&gt;
  &lt;/form:form&gt;
  </code></pre>