title: Validation message not working in Thymeleaf
body: <p>I am new at Java. Using Thymeleaf and Spring-Boot.</p>
  
  <p>Trying to show validation message on wrong input.</p>
  
  <p>"Phone" property must be between 7 to 13 character long. Validation message will be shown if rules are not followed.</p>
  
  <p>Please note, validation works but message is not shown.</p>
  
  <p>Here is the Model</p>
  
  <pre><code>@Entity
  public class Author {
  
  @Column(name = "phone")
  @Size(min=7, max = 13, message = "The category name must be {min} to {max} characters in length.")
  private String phone;
  }
  </code></pre>
  
  <p>the Controller</p>
  
  <pre><code>@Controller
  @RequestMapping("/author")
  public class AuthorController extends WebMvcConfigurerAdapter {
  
  @Autowired
  AuthorService authorService;
  
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
      registry.addViewController("/new-author").setViewName("newauthor");
  }
  
  @RequestMapping(value="/new-author", method = RequestMethod.GET)
  public String newAuthor(Model model){
  
      Author author = new Author();
      model.addAttribute("addNewAuthor", author);
  
      return "newauthor";
  }
  
  @RequestMapping(value="/new-author", method = RequestMethod.POST)
  public String newAuthor(@Valid  Author author, BindingResult bindingResult, Model model){
  
      model.addAttribute("addNewAuthor", author);
  
      if (bindingResult.hasErrors()) {
          return "newauthor";
      }
  
      try{
  
          authorService.createAuthor(author);
          model.addAttribute("statusReport", "Author Saved");
      }
  
      catch (Exception e){
  
          model.addAttribute("statusReport", "Author not Saved");
      }
  
      return "newauthor";
  }
  }
  </code></pre>
  
  <p>here is the View</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
  &lt;title&gt;Add Author&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;link rel="stylesheet" href="../public/bootstrap-3.3.6-     dist/css/bootstrap.css" th:href="@{/bootstrap-3.3.6-dist/css/bootstrap.css}"/&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Add New Author&lt;/h1&gt;
  &lt;div class="col-lg-3" &gt;
  &lt;form role="form" action="#" th:action="@{/author/new-author}"  th:object="${addNewAuthor}" method="post"&gt;
  
  
  &lt;div th:class="form-group" th:classappend="${#fields.hasErrors('phone')}? 'has-error'"&gt;
      &lt;label&gt;Phone&lt;/label&gt;
      &lt;input class="form-control" type="text" th:field="*{phone}" placeholder="Enter author's phone number"/&gt;
      &lt;p th:if="${#fields.hasErrors('phone')}" class="label label-danger" th:errors="*{phone}"&gt;Phone Error&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;button type="submit" class="btn btn-default"&gt;Add&lt;/button&gt;
  &lt;button type="reset" class="btn btn-default"&gt;Reset&lt;/button&gt;
  
  &lt;p th:text="${statusReport}" &gt; &lt;/p&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>