spring-boot - 如何在 Thymeleaf 中将 th:text 和静态内容与 html 标签连接起来?
问题描述
<div th:switch="${data.totalPercentage}">
<td th:case="100" th:text="${data.totalPercentage}"/>
<td th:case="*" th:text="${data.totalPercentage + '*'}" class="alert alert-warning font-weight-bold"/>
</div>
上面的表达式有效,但我无法将 html 标记与 th:text 连接起来。我想用 fontawesome flag icon 替换 * <i class="fas fa-flag"></i>
。有什么建议吗?
解决方案
没有真正的理由在这里连接,您应该考虑 HTML。
<div th:switch="${data.totalPercentage}">
<td th:case="100" th:text="${data.totalPercentage}"/>
<td th:case="*" class="alert alert-warning font-weight-bold">
<span th:text="${data.totalPercentage}" /> <i class="fas fa-flag"></i>
</td>
</div>
推荐阅读
- azure-webjobs - 通过 VS 在 WebJob 中编码时缺少 QueueAttribute
- c# - 类似 Blueprism 的间谍和机器人开发
- excel - 是否有在列列表中查找先前值的公式?
- python - 如何使用 tensorflow 实现两个张量的元素卷积?
- angular - 替换视角 7 的变量值
- java - 如何从android中的另一个应用程序以编程方式安装apk
- c++ - VS2017 + ICC 19.0:无法运行 MSBuild 命令
- netlogo - 如何让代理在特定滴答内停留在 netlogo 中的特定补丁?
- php - 无法将数据库分配给 2 个不同的用户
- django - Django 重置密码失败并出现 PasswordResetView