有没有办法告诉Thymeleaf,如果有任何字段有错误,就显示错误消息?
我现在将它们单独列出,如下所示:
<div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="validation-message alert alert-danger" role="alert"></div>
<div th:if="${#fields.hasErrors('lastName')}" th:errors="*{lastName}" class="validation-message alert alert-danger" role="alert"></div>
<div th:if="${#fields.hasErrors('firstName')}" th:errors="*{firstName}" class="validation-message alert alert-danger" role="alert"></div>发布于 2017-03-11 06:36:03
http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html#all-errors
应该能够做一些类似的事情:
<div th:each="err : ${#fields.errors('*')}" class="validation-message alert alert-danger" role="alert" th:text="${err}" />https://stackoverflow.com/questions/42728692
复制相似问题