[英]Thymeleaf Variables
有没有办法告诉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>
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}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.