title: Spring Validator doesn't show error message
body: <p>I have a problem with my UserValidator class. I'm trying to validate 2 fields of form: username and email and only in case of username the messahe is showing. It's weird for me, because i'm doing it the same way in both cases.</p>
  
  <p>I have <strong>globalmessages.properties</strong> file with my error messages:</p>
  
  <pre><code>same.mail=Email exists, type other email!
  equal.user=Username exists, type other username!
  </code></pre>
  
  <p>UserValidator class is validated in Controller in that way:</p>
  
  <pre><code>@Autowired
  private UserValidator userValidator;
  
  @RequestMapping(value = "/adduser", method = RequestMethod.GET)
      public String addUser(@Valid @ModelAttribute(value = "user") User user, BindingResult result) {
  userValidator.validate(user, result);
  return "signin";
  }
  </code></pre>
  
  <p>In validate method i'm checking if user exists in db and if so error is registered. Then i'm doing the same with email. That's UserValidator's validate method:</p>
  
  <pre><code>@Override
      public void validate(Object target, Errors errors) {
  
          User user = (User) target;
  
          //check if user exists
          Users users = usersDAOImpl.checkByUsername(user.getUsername());
          //check if email exists
          Emails email = usersDAOImpl.checkByEmail(user.getEmail());
  
          String emailAddresse = email == null ? "null" : "not null";
  
          System.out.println("From UserValidator class, before rejecting values- email: "
                  + emailAddresse);
  
          if (users != null)
          {
              errors.rejectValue("username", "equal.user");
              System.out.println("From UserValidator class - user not null: "
                      + users.getUsername());
          }
  
          if (email != null) 
          {
              errors.reject("email", "same.mail");
              System.out.println("From UserValidator class - email not null: "
                      + email.getEmail());
          }
      }
  </code></pre>
  
  <p>There's my signin form:</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;%@ page session="false" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Home&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form:form modelAttribute="user" method="get" action="${pageContext.request.contextPath}/adduser" &gt;
      &lt;table align="left"&gt;
          &lt;tr&gt;
              &lt;td&gt;Username&lt;/td&gt;
              &lt;td&gt;&lt;form:input path="username" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;font color="red"&gt;&lt;form:errors path="username"&gt;&lt;/form:errors&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Password&lt;/td&gt;
              &lt;td&gt;&lt;form:input type="password" path="password" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;font color="red"&gt;&lt;form:errors path="password"&gt;&lt;/form:errors&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Confirm password&lt;/td&gt;
              &lt;td&gt;&lt;form:input type="password" path="confpassword" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;font color="red"&gt;&lt;form:errors path="confpassword"&gt;&lt;/form:errors&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;E-mail&lt;/td&gt;
              &lt;td&gt;&lt;form:input type="email" path="email" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;font color="red"&gt;&lt;form:errors path="email"&gt;&lt;/form:errors&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" value="Create user"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form:form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When i type existing username and submit the form, the error for username from globalmessages.properties is displaying and when i type existing email, error message isn't displaying, although usersDAOImpl.checkByEmail method works fine and i can see "From UserValidator class - email not null: " + email.getEmail() on console.</p>