迭代酒店列表。每当列表为空时它给我错误
<div class="row list" th:if="${#lists.size(hotels) > 0}" th:each="hotelChunk : ${T(com.google.common.collect.Lists).partition(hotels, ${#lists.size(hotels)})}">
<!-- single result item -->
<div th:each="hotel : ${hotelChunk}" class="col-md-4 single-result" >
错误是:
HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "T(com.google.common.collect.Lists).partition(hotels, ${#lists.size(hotels)})" (search:44)
有任何解决方法可以解决这个问题吗?
答案 0 :(得分:0)
您必须将th:each
更改为:
th:each="hotelChunk : ${T(com.google.common.collect.Lists).partition(hotels, #lists.size(hotels))}"
在当前的Thymeleaf表达式中不需要再次使用${..}
。