java - 如何使用 thymeleaf 在同一个 html 表格行中显示 2 个弹簧模型?
问题描述
我想在 html 表中显示以下行:
"$num out of $totalCount"
例如num=5
,totalCount=8
我想在表格中看到5 out of 8
这是我的代码:
...
<tr>
<td th:text="${num} out of ${totalCount}" />
</tr>
...
我在控制器中添加了num
和totalCount
作为模型。
我收到以下错误:
Could not parse as expression: "${num} out of ${totalCount}"
这样做的正确语法是什么?
解决方案
Thymeleaf 中有几个用于字符串连接的选项。有关概述,请参阅使用 Thymeleaf 进行字符串连接。
在这种情况下,您可以使用以下内容:
<td th:text="|${num} out of ${totalCount}|" />
推荐阅读
- git - Github 甚至会阻止来自允许地址的推送。我该如何解决?
- python - 如果 mixin 的目标类继承自元类,如何键入提示 mixins?
- typescript - 纯 TypeScript npm 包
- excel-formula - 如何在每个月的第一天对上个月excel中的值求和
- redirect - AEM - 通过调度程序访问受限页面重定向到发布者登录页面
- python - python中基类的重复数据名称
- python-3.x - 使用 dtype=Objects 构建和拆分二维数组
- swift - 如何获取保存在 Firebase 存储中的视频的 URL
- python - 使用 pydrive 模块在 Gdrive 上创建新文件夹
- c# - 使用 Migrations、Code First Entity Framework Core 插入大数据种子