title: spring form validation BindingResult always returns false
body: <p>i am using spring form validation to validate my form input fields..I am having problem with BindingResult where result.hasErrors() is always returning false even though my input fields are null/empty..i managed all the imports and everything is looking fine to me.But as I said, my validation is not working and needs help with fixing this...</p>
  
  <p>form:</p>
  
  <pre><code>  &lt;%@include file="././Header.jsp"%&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;script src="&lt;c:url value="/js/smlibray/emailCommunicate.js"/&gt;"&gt;&lt;/script&gt;
   &lt;link href="&lt;c:url value="/js/jquery-ui.css"/&gt;" rel="stylesheet" /&gt;
  &lt;script src="&lt;c:url value="/js/jquery-ui.js"/&gt;"&gt;&lt;/script&gt;
  
  &lt;input type="hidden" name="applicationUrl" id="applicationUrl"
      value="${pageContext.request.contextPath}"&gt;
  
  &lt;div class="container sec-container middle-sec"&gt;
      &lt;div class="form-fields row"&gt;
          &lt;div class="col-md-12 col-sm-12 col-xs-12"&gt;
              &lt;form:form class="form-horizontal policy-form" id="emailCommu-form"  method="POST" action="sendEmailMessage" commandName="emailForm"&gt;
                  &lt;div class="form-group"&gt;
                  &lt;h1 class="email-header"&gt;SiteMidner Email Notification&lt;/h1&gt;
                  &lt;c:choose&gt;
                      &lt;c:when test="${not empty sMsg}"&gt;
                          &lt;div class="email-Commu-SMsg"&gt;* ${sMsg}&lt;/div&gt;
                      &lt;/c:when&gt;
                      &lt;c:otherwise&gt;
                          &lt;c:if test="${not empty eMsg}"&gt;
                              &lt;div class="email-Commu-EMsg"&gt;* ${eMsg}&lt;/div&gt;
                          &lt;/c:if&gt;
                      &lt;/c:otherwise&gt;
                  &lt;/c:choose&gt;
                  &lt;div class="form-emailCommu"&gt;
                      &lt;label for="emailSub-txtArea" class="email-ContentHead"&gt;Enter
                          the Subject Line for the Email : &lt;/label&gt;
                      &lt;div class="email-sm-textDiv"&gt;
                          &lt;form:textarea path="emailSubject" name="emailSubject" id="emailSubTxtArea"
                              placeholder="Email Subject"/&gt;
                      &lt;/div&gt;
                      &lt;span&gt;&lt;form:errors path="emailSubject" cssClass="error" /&gt;&lt;/span&gt;
  
                  &lt;/div&gt;
  
                  &lt;div class="form-emailCommu"&gt;
                      &lt;label for="emailBod-txtArea" class="email-ContentHead"&gt;Enter
                          the Message Body for the Email : &lt;/label&gt;
                      &lt;div class="email-sm-textDiv"&gt;
                          &lt;form:textarea path="emailMsg" name="emailMsg" id="emailBodyTxtArea"
                              placeholder="Email Body"/&gt;
                      &lt;/div&gt;
                      &lt;span&gt;&lt;form:errors path="emailMsg" cssClass="error" /&gt;&lt;/span&gt;
  
                  &lt;/div&gt;
  
                  &lt;div class="email-sendButton"&gt;
                      &lt;input type="submit" class="styled-button" value="Send Email"&gt;&lt;/input&gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/form:form&gt;
  
          &lt;/div&gt;
          &lt;!--form-fields close --&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>controller code:</p>
  
  <pre><code>@RequestMapping(value="/sendEmailMessage",method=RequestMethod.POST)
  public ModelAndView sendEmailCommunication(@Valid @ModelAttribute("emailForm") EmailReqInfo emailInfo,BindingResult result,HttpServletRequest request){
      ModelAndView view = null;
      StringBuffer sMsg = new StringBuffer();
      StringBuffer eMsg = new StringBuffer();
      boolean isAdmin = false;
      try{
      String loggedInUser = request.getHeader("sm_user").trim();
       isAdmin = getUserAdminRights(request);
  
       if(result.hasErrors()){
           view = new ModelAndView("EmailCommunication");
           view.addObject("isAdmin", isAdmin);
           return view;
       }
       else{
          String emailSubject = emailInfo.getEmailSubject();
          String emailMsg  = emailInfo.getEmailMsg().replace("\n", "&lt;br /&gt;\n");
      boolean status = emailService.sendEmailCommuncation(emailSubject,emailMsg);
      if(status){
          sMsg.append(" Sending SiteMinder Notification Email was Success.");
      }
      else{
          eMsg.append(" Oops! Something went wrong while sending Email Notification. Pls check logs");
      }
      }
      }
      catch(Exception ex){
          ex.printStackTrace();
          eMsg.append("Oops! Something went wrong while sending Email Notification. Pls check logs");
      }
      view = new ModelAndView("EmailCommunication");
      view.addObject("emailForm", new EmailReqInfo());
      view.addObject("isAdmin", isAdmin);
      view.addObject("sMsg", sMsg.toString());
      view.addObject("eMsg", eMsg.toString());
      return view;
  }
  </code></pre>
  
  <p>email Model:</p>
  
  <pre><code>import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Size;
  
  import org.hibernate.validator.constraints.NotEmpty;
  
  public class EmailReqInfo 
  {
  
      @NotNull @NotEmpty
      @Size(min=1)
      private String emailSubject;
      @NotNull @NotEmpty
      private String emailMsg;
      public String getEmailSubject() {
          return emailSubject;
      }
      public void setEmailSubject(String emailSubject) {
          this.emailSubject = emailSubject;
      }
      public String getEmailMsg() {
          return emailMsg;
      }
      public void setEmailMsg(String emailMsg) {
          this.emailMsg = emailMsg;
      }
  }
  </code></pre>
  
  <p>i have the necessary annotation in my spring-mvc.xml</p>
  
  <pre><code>&lt;mvc:annotation-driven&gt;
      &lt;mvc:message-converters register-defaults="false"&gt;
      &lt;bean id="jacksonMessageConverter" 
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/&gt;
    &lt;/mvc:message-converters&gt;
    &lt;/mvc:annotation-driven&gt;
  </code></pre>
  
  <p>help needed in fixing the validation..thanks</p>