title: @Range not working in spring mvc
body: <p>I am using spring mvc and trying to validate user input in a form <code>addGoal.jsp</code> by using <code>@Range</code> in my model <code>Goal</code>.But if I enter value for ex <code>223</code> greater than <code>120</code> as I set in the annotation it prints <code>Result Errors false</code>(as I printed in updateGoal method in controller) and not routing to <code>addGoal</code> view I cant seem to understand why its not validating the <code>result.hasErrors()</code> giving me false even if I enter value that are not in range.</p>
  
  <p>Model</p>
  
  <pre><code>import org.hibernate.validator.constraints.Range;
  
  public class Goal {
  
      @Range(min = 1,max = 120)    // validation not working
      private int minutes;
  
      public int getMinutes() {
          return minutes;
      }
  
      public void setMinutes(int minutes) {
          this.minutes = minutes;
      }
  
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>import javax.validation.Valid;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.SessionAttributes;
  
  import testspring.model.Goal;
  
  @Controller
  @SessionAttributes("goal")
  public class GoalController {
  
  
      @RequestMapping(value = "/addGoal",method = RequestMethod.GET)
      public String addGoal(Model model){
          Goal g=new Goal();
          g.setMinutes(10);
          model.addAttribute("goal", g);
          return "addGoal";       
      }
      @RequestMapping(value = "/addGoal",method = RequestMethod.POST)
      public String updateGoal(@Valid @ModelAttribute ("goal") Goal goal,BindingResult result){
  
          System.out.println("Result Errors "+result.hasErrors());
          System.out.println("Minutes Updated "+goal.getMinutes());
          if(result.hasErrors())
          return "addGoal";
          return "redirect:addMinutes.html";      
      }
  
  }
  </code></pre>
  
  <p>addGoal.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
          &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form:form commandName="goal"&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Enter Minutes&lt;/td&gt;
  &lt;td&gt;&lt;form:input path="minutes"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan="2"&gt;
  &lt;input type="submit" value="Enter Goal Minutes"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>servlet-config.xml</p>
  
  <pre><code>    &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:mvc="http://www.springframework.org/schema/mvc" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="
              http://www.springframework.org/schema/beans     
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/context 
              http://www.springframework.org/schema/context/spring-context-3.0.xsd
              http://www.springframework.org/schema/mvc
              http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
          &lt;context:component-scan base-package="testspring" /&gt;
  
          &lt;mvc:annotation-driven /&gt;
          &lt;mvc:resources location="pdfs" mapping="/pdfs/**"/&gt;
  
          &lt;mvc:interceptors&gt;
  
          &lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
          &lt;property name="paramName" value="language"&gt;&lt;/property&gt;
          &lt;/bean&gt;
          &lt;/mvc:interceptors&gt;
  
          &lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"&gt;
          &lt;property name="defaultLocale" value="en"&gt;&lt;/property&gt;
          &lt;/bean&gt;
  
  
          &lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" &gt;
        &lt;property name="basename" value="messages"&gt;&lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
          &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt;
          &lt;/bean&gt;
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;testspring&lt;/groupId&gt;
    &lt;artifactId&gt;FitnessTracker&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;FitnessTracker Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;3.2.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;4.2.0.Final&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;finalName&gt;FitnessTracker&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I have posted my xmls in order anyone wants to see.</p>
  
  <p>Any help would be appreciated.<br>
  Thanks </p>