Spring MVC validation errors are not displayed in Freemarker template
<p>I'm trying to display validation errors in a 'user registration' page built with freemarker template if a controller returns binding errors.</p>

<p>My controller's code is as follows:</p>

<pre><code>@Controller
@RequestMapping("/")
public class UserController  {

@Autowired
private UserService userService;

@Autowired
private SecurityService securityService;

@Autowired
private UserValidator userValidator;

@RequestMapping(value = "/registration", method = RequestMethod.GET)
   public String registration(Model model) {
   model.addAttribute("userForm", new User()); 
   return "registration";
  }

@RequestMapping(value = "/registration", method = RequestMethod.POST)
public String registration(@ModelAttribute("useraccount") User userForm,     BindingResult bindingResult, Model model) {

    userValidator.validate(userForm, bindingResult);

    if (bindingResult.hasErrors()) {

        return "registration";
        }

    userService.save(userForm);

    securityService.autologin(userForm.getUsername(), userForm.getPasswordConfirm());

    return "redirect:/explore";
}
</code></pre>

<p>while this is the registration.ftl freemarker template I am trying to build :</p>

<pre><code> &lt;div&gt;
&lt;fieldset&gt;
    &lt;h1&gt;Create your Account&lt;/h1&gt;
    &lt;form id="regForm" class="idealform" action="registration" method="post" name='useraccount'&gt;
            Username: &lt;input type="text" name="username" /&gt; &lt;errors path="username" cssClass="error"/&gt;&lt;br/&gt;
            Password: &lt;input type="text" name="password" /&gt;&lt;errors path="password" cssClass="error"/&gt;&lt;br/&gt;
               &lt;label class="main-label" style="width: 91px;"&gt;&amp;nbsp;&lt;/label&gt;
        &lt;input type="submit" value="submit"&gt;
    &lt;/form&gt;
&lt;/fieldset&gt;
</code></pre>

<p></p>

<p>I tried also the solution recommended here:</p>

<p><a href="https://stackoverflow.com/questions/7556733/displaying-spring-mvc-validation-errors-in-freemarker-templates">Displaying Spring MVC validation errors in Freemarker templates</a></p>

<p>and the  registration.ftl becomes:</p>

<pre><code>  &lt;#assign form=JspTaglibs["http://www.springframework.org/tags/form"] /&gt;

  &lt;#macro formErrors&gt;
  &lt;#assign formErrors&gt;&lt;@form.errors path="*" /&gt;&lt;/#assign&gt;
  &lt;#if formErrors?has_content&gt;
    &lt;div id="errors"&gt;
     &lt;@spring.message "admin.error.globalMessage" /&gt;
    &lt;/div&gt;
  &lt;/#if&gt;
 &lt;/#macro&gt;

&lt;div&gt;
&lt;fieldset&gt;
    &lt;h1&gt;Create your Account&lt;/h1&gt;
    &lt;@form.form id="regForm" class="idealform" action="registration"   method="post" name='useraccount'&gt;
            Username: &lt;input type="text" name="username" path="username" /&gt;    &lt;br/&gt;

            Password: &lt;input type="text" name="password" path="password" /&gt;&lt;br/&gt;

    &lt;@formErrors /&gt;
        &lt;label class="main-label" style="width: 91px;"&gt;&amp;nbsp;&lt;/label&gt;
        &lt;input type="submit" value="submit"&gt;
    &lt;/@form.form&gt;
&lt;/fieldset&gt;

&lt;/div&gt;
</code></pre>

<p>but still the validation messages are not displayed.</p>

<p>Could you share your thoughts with me on this issue?
Thank you very much.</p>