title: Spring form input value get lost when manually add FieldError into bindingResult
body: <p>I have a web controller in Spring MVC:</p>
  
  <pre><code>@RequestMapping("/")
  public String create(@Valid @ModelAttribute Device device, BindingResult bindingResult) {
      return getDefaultView();
  }
  </code></pre>
  
  <p>jsp view:</p>
  
  <pre><code>&lt;form:form role="form" commandName="device"&gt;
      &lt;form:input path="name" class="form-control"/&gt;
      &lt;form:errors path="name" cssClass="text-danger"/&gt;
      &lt;button type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>Suppose that my Device class has only one attribute <strong>name</strong>. I want to validate it (example length >= 5)</p>
  
  <pre><code>public class DeviceDTO {
      @Size(min = 5)
      String name;
      //getter &amp; setter..
  }
  </code></pre>
  
  <p>After run this, I input string "abc" in <strong>name</strong> field then submit, The form will show as:
  <a href="https://i.stack.imgur.com/J3oBa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J3oBa.png" alt="enter image description here"></a></p>
  
  <p>We can see there are old value &amp; error message. But in some cases that I want to manually validate with my own criteria (that annotation cannot handle), I remove @Size annotation and change my controller like this:</p>
  
  <pre><code>@RequestMapping("/")
  public String create(@Valid @ModelAttribute Device device, BindingResult bindingResult) {
      if(device.getName().length() &lt; 6)
          bindingResult.addError(new FieldError("device", "name", "custom error"));
      return getDefaultView();
  }
  </code></pre>
  
  <p>But now, when I submit form with "abc" value, my custom error is shown but my old value of <strong>name</strong> field not
  <a href="https://i.stack.imgur.com/7Pkye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Pkye.png" alt="enter image description here"></a></p>
  
  <p>But if I use directly ${device.name}, it still shows "abc" value.</p>