How to display server side field validation errors with Bootstrap and Thymeleaf
<form action="#" th:action="@{/}" th:object="${myForm}" method="post"> <!-- 'myform' is the form object -->
<!-- start row 1 -->
<div class="form row">
<!-- col 1 -->
<div class="col-lg-6">
<div class="form-group">
<label th:for="*{firstname}">First name</label>
<input th:field="*{firstname}" type="text" class="form-control"
th:classappend="${#fields.hasErrors('firstname')}? is-invalid" <!-- adds this class in case there is a field error-->
placeholder="first name"
aria-describedby="firstnameFeedback"> <!-- see server-side validation from Bootstrap docs -->
<div id="firstnameFeedback" th:if="${#fields.hasErrors('firstname')}"
th:errors="*{firstname}" class="invalid-feedback"> <!-- is initially not displayed -->
</div>
</div>
(...)