【发布时间】:2018-09-19 10:48:31
【问题描述】:
尝试在引导表单中添加带有错误验证样式的文本
这是表格的一部分:
<label th:text="#{name}"
class="col-form-label col-form-label-sm"></label>
<input
type="text" class="form-control form-control-sm"
th:field="*{name}" />
<span
th:if="${#fields.hasErrors('name')}" th:errors="*{name}"
th:class="invalid-feedback">Here there is an error</span>
我收到有关验证错误的消息,但没有样式。
如果我调试,我会看到具有以下样式的类:
<span class="invalid-feedback">Here there is an error</span>
我已经尝试过几种样式,例如 help-block 但没有办法。
我正在使用 bootstrap4.0.0-alpha.6
有什么想法吗?
谢谢
【问题讨论】:
-
您可以删除
th:class中的th:。当涉及变量并且需要 Thymeleaf 对其进行评估时,您基本上需要使用th:。 -
无论有无,该类均不适用。使用内联样式临时解决
标签: java spring-boot bootstrap-4 thymeleaf