【发布时间】:2016-02-20 15:14:20
【问题描述】:
我的环境是使用 Thymeleaf 的 Spring Boot 1.2.7.RELEASE。
我验证了可以正常工作的字段,但我想对错误消息进行一些格式化。我似乎在服务器端的消息中输入的任何内容都会转义传递到我的页面,所以我想我必须在我的 Thymeleaf 模板中使用 css 执行此操作。
但是怎么做呢?我已经尝试了很多东西,比如:
<label for="password" title="Enter your password here">Password</label>
<input type="password" name="password" id="password" th:field="*{password}" cssErrorClass="form-field-error" size="15"/>
<p class="form-error-text" th:if="${#fields.hasErrors('password')}" th:errors="*{password}">There was a problem with your password</p>
这会导致根本不呈现错误文本。如果我删除 class="form-field-text" 我会收到错误消息以呈现 int eh 正确的位置。
所以我想底线是,如何将 css 类应用于验证错误文本?
【问题讨论】:
标签: css spring-boot thymeleaf