Question: I'm trying to display a list of global validation errors in my freemarker template if a controller returns binding errors. I can display errors that are associated with a field, but I want to detect when an error has occurred within a specific bean and display a message at the top of the page. I've tried using the example below which produces no output: 

```
<@spring.bind "webPage" />
....
<#if spring.status.error>
There were problems with the data you entered:
<ul>
<#list spring.status.errorMessages as error>
<li>${error?html}</li>
</#list>
</ul>
</#if>

```

The line below always returns 0, despite there being errors with the submitted form:

```
${spring.status.errorMessages?size}

```

My controller code is below:

```
@RequestMapping(method = RequestMethod.POST)
public ModelAndView save(@ModelAttribute("webPage") @Valid WebPage page, BindingResult result, Model model) {
    if (!model.containsAttribute("site")) {
        throw new IllegalArgumentException("Model must contain site attribute.");
    }
    Site site = (Site) model.asMap().get("site");
    if (!result.hasErrors() && !page.isNew()) {
        this.pageService.save(page, site);
    } else if (!result.hasErrors() && page.isNew()) {
        this.pageService.create(page, site);
    } 
    return createMav(result);
}

```

The createMav method is below:

```
public ModelAndView createMav(BindingResult result) {
    ModelAndView mav = new ModelAndView();
    mav.setViewName(getPrimaryControllerView());
    mav.addAllObjects(result.getModel());
    return mav;
}

```

Is there a way to achieve this using Freemarker + Spring MVC?

Answer: 
You can write as follows:

```
<#if spring.status.error>
<ul>
   <#list spring.status.errors.globalErrors as error>
   <li>${error.defaultMessage}</li>   
   </#list>
</ul>
</#if>

```

More info at [BindStatus](http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/support/BindStatus.html) and [Errors](http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/validation/Errors.html) classes.
See the documentation: <http://static.springsource.org/spring/docs/current/spring-framework-reference/html/view.html#view-velocity-forms>. It has an example of what you want to do.