title: Spring MVC 3 validation with annotations - not showing form:errors
body: <p>I've been stuck with this about one hour, this is not the first time i am doing this but I cant figure it out.</p>
  
  <p>It should show me the form errors, instead it throws this exception.</p>
  
  <p>LE: i managed to solve the exception in the meantime, but i still cant see the errors. they are not rendered</p>
  
  <blockquote>
    <p>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
    Field error in object 'category' on field 'name': rejected value [jk]; codes [Range.category.name,Range.name,Range.java.lang.String,Range]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [category.name,name]; arguments []; default message [name],25,3]; default message [gfhghj]
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
        org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
        org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
        org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
        org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)</p>
  </blockquote>
  
  <pre><code>@Controller
  @RequestMapping("/category")
  public class CategoryController {
  
  @Autowired
  StockGateway stockGateway;
  
  @RequestMapping(value = "add", method = RequestMethod.POST)
  public String addCategory(@Valid @ModelAttribute("category") CategoryAdd category, ModelMap model,
          BindingResult binding) {
  
      if (binding.hasErrors()) {
          return "category.add";
      }
      CategoryDTO dto = Converter.toCategory(category);
      try {
          stockGateway.createCategory(dto);
      } catch (StockGatewayException e) {
          e.printStackTrace();
      }
      return "redirect:/category/add";
  
  }
  
  @RequestMapping(value = "add", method = RequestMethod.GET)
  public String initView(ModelMap model) {
      model.put("category", new CategoryAdd());
      return "category.add";
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;div xmlns:jsp="http://java.sun.com/JSP/Page" 
  xmlns:spring="http://www.springframework.org/tags"
   xmlns:c="http://java.sun.com/jsp/jstl/core" 
   xmlns:security = "http://www.springframework.org/security/tags"
   xmlns:util="urn:jsptagdir:/WEB-INF/tags/util"
   xmlns:form="http://www.springframework.org/tags/form"
   version="2.0"&gt;
  </code></pre>
  
  <p>
    
    </p>
  
  <pre><code>&lt;security:authorize access="hasRole('ROLE_STOCK')" var="isStock"&gt;
      &lt;form:form modelAttribute="category"  method="POST" action="add"  &gt;
              &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Name  :&lt;/td&gt; &lt;td&gt; &lt;form:input path="name" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;/td&gt; &lt;td&gt; &lt;form:errors path="name" cssClass="error" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;/table&gt;
              &lt;form:button&gt;Add&lt;/form:button&gt;
      &lt;/form:form&gt;
  &lt;/security:authorize&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>public class CategoryAdd {
  
  @Range(min= 3 , max = 25, message="gfhghj")
  private String name;
  
  
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  </code></pre>