Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Spring + Thymeleaf form validation error not displaying

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error: org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "watchlistItemForm" - line 47, col 26)

Please help. I have spent hours troubleshooting and googling.

controller:




watchlistItemForm.html



<html xmlns:th="http://www.thymeleaf.org">
  <head>
        <meta charset = "utf-8">
        <meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
        <link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
        <title>Watchlist App</title>
     </head>
 <body>
    <div class = "container">
      <nav class = "navbar navbar-expand-sm navbar-dark bg-secondary">
          <a class = "navbar-brand" href = "homepage-static.html">Watchlist App</a>
          <button class = "navbar-toggler" type = "button" data-toggle = "collapse"
             data-target = "#navbarSupportedContent"
             aria-controls = "navbarSupportedContent" aria-expanded = "false"
             aria-label = "Toggle navigation">

             <span class = "navbar-toggler-icon"></span>
          </button>

          <div class = "collapse navbar-collapse" id = "navbarSupportedContent">
             <ul class = "navbar-nav mr-auto">
                <li class = "nav-item">
                   <a class = "nav-link" href = "/">Home</a>
                </li>
                <li class = "nav-item">
                   <a class = "nav-link" href = "watchlist">Watchlist</a>
                </li>
                <li class = "nav-item active">
                   <a class = "nav-link" href = "watchlistItemForm">Submit an item</a>
                </li>
             </ul>

          </div>
      </nav>        
       <form action="#" th:action="@{/watchlistItemForm}" th:object="${commandObj}" method="post" >
          <h2 class = "mt-4">Submit an item</h2>
          <hr/>
          <!-- Form levels error messages here -->
          <div class = "form-group row ">
             <div class="col-sm-8">
                  <span class="text-danger" > </span>      
              </div>
          </div>
          <div class = "form-group row ">
             <label for = "title" class = "col-sm-2 col-form-label">Title</label>
             <div class = "col-sm-4">
                <input th:field="*{title}" type = "text" class = "form-control" placeholder = "Mandatory">
             </div>
             <div class="col-sm-4">
                <span th:if="${#fields.hasErrors('title')}" th:errors="*{title}">title Error</span>

             </div>
          </div>

          <div class = "form-group row ">
             <label for = "rating" class = "col-sm-2 col-form-label mr-0">Rating</label>
             <div class = "col-sm-4">
                <input type = "text" th:field = "*{rating}" class = "form-control" placeholder = "5.0 < Number < 10.0">
             </div>
             <div class="col-sm-4">
                  <span class="text-danger"> </span>      
              </div>
          </div>

          <div class = "form-group row ">
             <label for = "priority" class = "col-sm-2 col-form-label mr-0">Priority</label>
             <div class = "col-sm-4">
                <input type = "text" th:field = "*{priority}" class = "form-control" placeholder = "Low|Medium|High">
             </div>
             <div class="col-sm-4">
                  <span class="text-danger"> </span>      
              </div>
          </div>

          <div class = "form-group row">
              <label for = "comments" class = "col-sm-2 col-form-label">Comments</label>
             <div class = "col-sm-4">
                <textarea th:field="*{comment}" class = "form-control" rows = "3" placeholder = "Max. 50 chars"></textarea>
             </div>
             <div class="col-sm-4">
                <span th:if="${#fields.hasErrors('comment')}" th:errors="*{comment}">Comment Error</span>
             </div>
          </div>
          <input type="hidden" th:field="*{id}" />
          <div class = "form-group row">
             <div class = "col-sm-10">
                <button type = "submit" class = "btn btn-primary">Submit</button>
             </div>            
          </div>

       </form>
    </div>

    <script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"> </script>
    <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" > </script>
    <script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" > </script>
 </body>
  </html>


Model Class



 
get schwifty. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!