private LinkedHashMap<String, String> openingAreaSelect = new LinkedHashMap<>();
<div th:each="items : ${form.openingAreaSelect}" >
<h5 th:text="${items.key}"></h5>
<h5 th:text="${items.value}"></h5>
<h5 th:text="${items.last}"></h5>
</div>
正常th:each LIST的话可以items.key,items.value,items.index,items.last都能用
现在openingAreaSelect是map类型,只有key和value能用,写last的话报错
Property or field 'last' cannot be found on object of type 'java.util.LinkedHashMap$Entry' - maybe not public or not valid?
我该怎么样判断循环是否到最后一次
从报错来看,循环变量items是map的entry对象,这个肯定没得last。
在JAVA代码获取最后一个,多传递个属性呗!
而且你这个写法一开始就得取最后一个,每次循环都得取。
如果只是特殊处理最后一个的话应该与entry的before after用法有关,手机上看,没代码,明天试试