Spring - Thymeleaf: Exception processing template
I fixed with this code adding delivery
prefix:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Taco Cloud</title>
<link rel="stylesheet" th:href="@{/styles.css}" />
</head>
<body>
<form method="POST" th:action="@{/orders}" th:object="${order}">
<h1>Order your taco creations!</h1>
<img th:src="@{/images/TacoCloud.png}"/>
<h3>Your tacos in this order:</h3>
<a th:href="@{/design}" id="another">Design another taco</a><br/>
<ul>
<li th:each="taco : ${order.tacos}"><span th:text="${taco.name}">taco name</span></li>
</ul>
<div th:if="${#fields.hasErrors()}">
<span class="validationError">
Please correct the problems below and resubmit.
</span>
</div>
<h3>Deliver my taco masterpieces to...</h3>
<label for="deliveryName">Name: </label>
<input type="text" th:field="*{deliveryName}"/>
<span class="validationError"
th:if="${#fields.hasErrors('deliveryName')}"
th:errors="*{deliveryName}">Name Error</span>
<br/>
<label for="deliveryStreet">Street address: </label>
<input type="text" th:field="*{deliveryStreet}"/>
<span class="validationError"
th:if="${#fields.hasErrors('deliveryStreet')}"
th:errors="*{deliveryStreet}">Street Error</span>
<br/>
<label for="deliveryCity">City: </label>
<input type="text" th:field="*{deliveryCity}"/>
<span class="validationError"
th:if="${#fields.hasErrors('deliveryCity')}"
th:errors="*{deliveryCity}">City Error</span>
<br/>
<label for="deliveryState">State: </label>
<input type="text" th:field="*{deliveryState}"/>
<span class="validationError"
th:if="${#fields.hasErrors('deliveryState')}"
th:errors="*{deliveryState}">State Error</span>
<br/>
<label for="deliveryZip">Zip code: </label>
<input type="text" th:field="*{deliveryZip}"/>
<span class="validationError"
th:if="${#fields.hasErrors('deliveryZip')}"
th:errors="*{deliveryZip}">Zip Error</span>
<br/>
<h3>Here's how I'll pay...</h3>
<label for="ccNumber">Credit Card #: </label>
<input type="text" th:field="*{ccNumber}"/>
<span class="validationError"
th:if="${#fields.hasErrors('ccNumber')}"
th:errors="*{ccNumber}">CC Num Error</span>
<br/>
<label for="ccExpiration">Expiration: </label>
<input type="text" th:field="*{ccExpiration}"/>
<span class="validationError"
th:if="${#fields.hasErrors('ccExpiration')}"
th:errors="*{ccExpiration}">CC Num Error</span>
<br/>
<label for="ccCVV">CVV: </label>
<input type="text" th:field="*{ccCVV}"/>
<span class="validationError"
th:if="${#fields.hasErrors('ccCVV')}"
th:errors="*{ccCVV}">CC Num Error</span>
<br/>
<input type="submit" value="Submit order"/>
</form>
</body>
</html>
Error during template parsing.Spring boot and Thymeleaf
Change
th:href="/@{/users}"
To
th:href="@{/users}"
By removing slash Before @
Thymeleaf exceptions for resolving template in spring boot
It seems as though you've incorrectly placed the file in the wrong folder. Try moving the it into the resources folder, it should be in src/main/resources
Otherwise, you'd need to manually configure that all templates be in src/main/webapp, but by default it's usually placed in resources
An error happened during template parsing Spring boot Thymeleaf
Your template is referring to an entry in the model named Student
:
<form action="#" th:action="@{/reg_success}" th:object="${Student}" method="post">
There's no such entry so an exception is thrown and this causes template parsing to fail.
You can fix the problem by updating your controller method that handles requests to /index
to add an entry named Student
to the model:
@GetMapping("/index")
public String sendForm(Model model) {
model.addAttribute("Student", new Student());
return "index";
}
This will then allow requests to /index
to succeed:
$ curl -i localhost:8080/index
HTTP/1.1 200
Content-Type: text/html;charset=UTF-8
Content-Language: en-GB
Transfer-Encoding: chunked
Date: Tue, 19 Jan 2021 12:33:45 GMT
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Add User</h1>
<form action="/reg_success" method="post">
<p>
Studnt ID: <input type="text" id="id" name="id" value="0">
</p>
<p>
Studnt Name: <input type="text" id="studentname" name="studentname" value="">
</p>
<p>
Studnt Course: <input type="text" id="course" name="course" value="">
</p>
<p>
<input type="submit" value="Submit"/> <input type="reset" value="Reset">
</p>
</form>
</body>
</html>
Related Topics
Handling Static Variables in Multithreaded Java Program
Error While Running Allure Command Line Generate Command
Regular Expression to Validate Username
Update Elements in a Jsonobject
Find Maximum Score or the Maximum Average Score of Candidate Scores Given in Two Dim Array
How to Specify the Required Java Version in a Gradle Build
How to Autowire a Component Which Is Having Constructor With Arguments in Springboot Application
Launching Spring Application Address Already in Use
How to Upload a Document to Sharepoint With Java
Using an Empty Keystore Password Used to Be Possible
Passing Data into HTML from Java Via Spring
Splitting a String Containing Special Characters in to Individual Characters
How to Get the Parent Element Name of a Child Element in Json
Maven: Best Way of Linking Custom External Jar to My Project
How to Remove All Special Character in a String Except Dot and Comma
How to Remove the Slashes from Json Key While Converting Object into String