Classappend and No-operation (_) in Thymeleaf
Purpose of th:classappend and no-operation (_)
Referring back to my previous example of checking validity of input fields by user
Observe this html with no-operation (_)
<input type="text" th:classappend=
"${errors?.containsKey('itemName')} ? 'field-error' : _"
class="form-control">
Through classappend, if there is an error with a particular field, it is added to the “field-error” class info and makes the form red for emphasis.
No-operation, as marked by the underscore (_), does not do anything. So if there is no error, it does nothing.