title: Validation and Freemarker
body: <p>We have to do validation on the page, in the case of empty fields to display a message.
  It's my class, the method of the controller and settings of messages.
  I can't to get on the page Freemarker display error messages.</p>
  
  <pre><code>public class CreateCourseDTO {
  @NotEmpty  
  private String name;
  @NotEmpty  
  private String category;
  @NotEmpty  
  private String description;
  @NotEmpty  
  private String links;
  
  public CreateCourseDTO() {
  }
  
  
  NotEmpty.createCourseDTO.name = Name is required!
  NotEmpty.createCourseDTO.category = Category is required!
  NotEmpty.createCourseDTO.description = Description is required!
  NotEmpty.createCourseDTO.links = Links is required!
  
  
  &lt;bean class="org.springframework.context.support.ResourceBundleMessageSource"
      id="messageSource"&gt;
      &lt;property name="basename" value="messages" /&gt;
  &lt;/bean&gt;
  
  
   @RequestMapping(value = "/create", method = RequestMethod.POST, params = {
          "name", "category", "description", "links" })
  public String createCoursePost(Model model, HttpSession session,
          HttpServletRequest request, @Valid CreateCourseDTO createCourseDTO,
          BindingResult result) {
      model.addAttribute("eMail", session.getAttribute("eMail"));
  
      String title = request.getParameter("name");
      String description = request.getParameter("description");
      String links = request.getParameter("links");
      String category = request.getParameter("category");
  
      if (result.hasErrors() ) {
  </code></pre>
  
  <p>How do I fix freemarker page?</p>
  
  <pre><code>&lt;#import "/spring.ftl" as spring /&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"/&gt;
  &lt;link rel="stylesheet" type="text/css" href="./css/style.css"/&gt;
  &lt;style&gt;
  .error {
  color: #ff0000;
  }
  
  .errorblock {
  color: #000;
  background-color: #ffEEEE;
  border: 3px solid #ff0000;
  padding: 8px;
  margin: 16px;
  }
  &lt;/style&gt;
  &lt;/head&gt;
   &lt;body&gt;
    &lt;div class="container"&gt;
    &lt;header&gt;
      &lt;h1&gt;
        Create Course
        &lt;div class="logout"&gt;
          &lt;span id="currentUserLogin"&gt;
            ${eMail}
          &lt;/span&gt;
          &lt;a href="logout.html"&gt;
            &lt;i class="icon-off"&gt;&lt;/i&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;/h1&gt;
    &lt;/header&gt;
  
  
  
    &lt;form class="form-horizontal" commandName="createCourseDTO"  method=POST&gt;
      &lt;fieldset&gt;
        &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;Name&lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;input id="name" name="name" class="span5" type="text"/&gt;
            &lt;@spring.showErrors "&lt;br&gt;"  /&gt;  
          &lt;/div&gt;
        &lt;/div&gt;
         &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;Category&lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;select id="category" name="category" class="span5"&gt;
              &lt;option&gt;&lt;/option&gt;
               &lt;#list listCategories as category&gt;
               &lt;option&gt;${category.category}&lt;/option&gt;
               &lt;/#list&gt;
           &lt;/select&gt;
           &lt;@spring.showErrors "&lt;br&gt;"  /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;Description&lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;textarea id="description" name="description" class="span5" rows="3"&gt;&lt;/textarea&gt;
            &lt;@spring.showErrors "&lt;br&gt;"  /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="control-group"&gt;
          &lt;label class="control-label"&gt;Links&lt;/label&gt;
          &lt;div class="controls"&gt;
            &lt;textarea id="links" name="links" class="span5" rows="3"&gt;&lt;/textarea&gt;
            &lt;@spring.showErrors "&lt;br&gt;"  /&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="form-actions"&gt;
          &lt;button id="createButton" name="createButton" class="btn btn-primary" type="submit"&gt;Create&lt;/button&gt;
  
        &lt;/div&gt;
      &lt;/fieldset&gt;
    &lt;/form&gt;
  
      &lt;a class="btn" href="courses.html"&gt;Cancel&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>