java - Thymeleaf (th:each + th:selected) :从每个循环访问选定属性中的变量
问题描述
如果某个列表包含来自每个循环的值,我想选择选项标签。但是从选定属性的循环中访问变量存在一些问题。这是我的代码:
<option th:each="facility: ${facilities}" th:value="${facility.id}" th:text="${facility.name}" th:selected="${apartment.facilities.contains(facility.id)}"></option>
下一个代码也不起作用:th:selected="${#lists.contains(apartment.facilities, facility.id)}"
它适用于th:selected="${apartment.facilities.contains(SOME_DIGIT)}"
and th:selected="${facility.id == SOME_DIGIT}"
。怎么了?
解决方案
解决方案:有不同的类型。List 包含 int 值,但我检查过 contains 的值类型很长。
推荐阅读
- spring - 如果应用程序启动失败,我们可以在spring中调用一个方法吗
- flutter - io_client.dart 中的 ClientException
- asp.net-core - 允许所有 HttpGet 请求的 ASP.NET Core 策略
- android-annotations - Android 注释的 Android Gradle 插件 5.0 版中非最终资源 ID 的后果是什么?
- google-sites - 如何用购买的谷歌域名更改谷歌的网站?
- julia - 替换Juila中的缺失值
- c# - 将来自不同类的值添加到 LIST,然后在另一个类中使用添加的值
- timer - 如何向 instaloader 添加自定义延迟
- algorithm - 如何找到埃拉托色尼筛算法的循环不变量?
- c++ - 这个 C++ 语法是什么意思?