Twitter bootstrap 将th:each与themelaf一起使用并对空列表应用分区会抛出错误
反复浏览酒店列表。每当列表为空时,它就会给我错误Twitter bootstrap 将th:each与themelaf一起使用并对空列表应用分区会抛出错误,twitter-bootstrap,spring-mvc,thymeleaf,Twitter Bootstrap,Spring Mvc,Thymeleaf,反复浏览酒店列表。每当列表为空时,它就会给我错误 <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 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" >
有没有解决这个问题的办法 您必须将
th:each
更改为:
th:each="hotelChunk : ${T(com.google.common.collect.Lists).partition(hotels, #lists.size(hotels))}"
无需在当前Thymeleaf表达式中再次使用
${..}
。我复制并粘贴了您的更改,但得到的错误是:HTTP状态500-请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessingException:exception评估SpringEL表达式:“T(com.google.common.collect.Lists).partition(hotels,#Lists.size(hotels))”是否使用缓存?清理并重新启动?嗨,帕特里克,我没有使用任何缓存。但仍然清除它并再次运行它。我也犯了同样的错误。我认为表达式T(com.google.common.collect.Lists).partition(hotels,#Lists.size(hotels))”存在问题,但还不能解决。奇怪的是,你能试着把一个固定的数字作为大小吗?即(4作为列表的大小):T(com.google.common.collect.Lists).partition(hotels,4)
th:each="hotelChunk : ${T(com.google.common.collect.Lists).partition(hotels, #lists.size(hotels))}"