Я думаю, что вы должны обработать отображение ошибок валидации во всех входных данных в файле orderForm.html, как указано в книге, следующим образом: (Source Git)
<!-- tag::allButValidation[] -->
<!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}"/>
<a th:href="@{/design}" id="another">Design another taco</a><br/>
<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="name">Name: </label>
<input type="text" th:field="*{name}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('name')}"
th:errors="*{name}">Name Error</span>
<!-- tag::allButValidation[] -->
<br/>
<label for="street">Street address: </label>
<input type="text" th:field="*{street}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('street')}"
th:errors="*{street}">Street Error</span>
<!-- tag::allButValidation[] -->
<br/>
<label for="city">City: </label>
<input type="text" th:field="*{city}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('city')}"
th:errors="*{city}">City Error</span>
<!-- tag::allButValidation[] -->
<br/>
<label for="state">State: </label>
<input type="text" th:field="*{state}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('state')}"
th:errors="*{state}">State Error</span>
<!-- tag::allButValidation[] -->
<br/>
<label for="zip">Zip code: </label>
<input type="text" th:field="*{zip}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('zip')}"
th:errors="*{zip}">Zip Error</span>
<!-- tag::allButValidation[] -->
<br/>
<h3>Here's how I'll pay...</h3>
<!-- tag::validatedField[] -->
<label for="ccNumber">Credit Card #: </label>
<input type="text" th:field="*{ccNumber}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('ccNumber')}"
th:errors="*{ccNumber}">CC Num Error</span>
<!-- tag::allButValidation[] -->
<!-- end::validatedField[] -->
<br/>
<label for="ccExpiration">Expiration: </label>
<input type="text" th:field="*{ccExpiration}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('ccExpiration')}"
th:errors="*{ccExpiration}">CC Num Error</span>
<!-- tag::allButValidation[] -->
<br/>
<label for="ccCVV">CVV: </label>
<input type="text" th:field="*{ccCVV}"/>
<!-- end::allButValidation[] -->
<span class="validationError"
th:if="${#fields.hasErrors('ccCVV')}"
th:errors="*{ccCVV}">CC Num Error</span>
<!-- tag::allButValidation[] -->
<br/>
<input type="submit" value="Submit order"/>
</form>
</body>
</html>
<!-- end::allButValidation[] -->
Я думаю, что вы не вставляете нужную информацию в форму в соответствии с правилами проверки, добавленными в bean-компонентах, как описано в главе. Отображая ошибку проверки, вы будете точно знать, какие данные введены неправильно при отправке заказа.
После изучения вашего кода. Имя атрибутов в файле Order.java не совпадает с именем на странице представления orderForm.html
Например, для orderForm атрибутом является name
<h3>Deliver my taco masterpieces to...</h3>
<label for="name">Name: </label>
<input type="text" th:field="*{name}"/>
Принимая во внимание, что в Order.java deliveryName .
@NotBlank(message="Delivery name is required")
private String deliveryName;
Решение состоит в том, чтобы использовать одно и то же имя атрибута на странице Order.java и orderForm.html.