【发布时间】:2018-09-19 19:31:11
【问题描述】:
下面有一些代码可以对控制器发送的数据进行分页:
<div class="col-xs-12 col-md-6">
<ul class="list-group">
<li class="list-group-item" th:each="history:${batchExecuteHistory}"
th:if="${history.status == true}">
<button type="button" class="btn btn-success">Success</button>
<span th:text="${history.timeEnd}"></span>
<span th:text="${history.rowInput}"></span>
</li>
<li class="list-group-item" th:each="history:${batchExecuteHistory}"
th:if="${history.status == false}">
<button type="button" class="btn btn-danger">Danger</button>
<span th:text="${history.timeEnd}"></span>
<span th:text="${history.errorContent}"></span>
</li>
</ul>
<ul class="pagination">
<li th:each='i : ${#numbers.sequence(0, nubmerOfPage.totalPages-1)}'
th:class="(${i}==${pnubmerOfPage.number})? 'active' : ''"
style="display: inline"><span th:if='${i}==${nubmerOfPage.number}'
th:text='${i+1}'>1</span> <a th:if='${i}!=${nubmerOfPage.number}'
th:href="@{${url}(nubmerOfPage=${i})}"> <span th:text='${i+1}'>1</span></a>
</li>
</ul>
</div>
我收到这样的错误:
org.thymeleaf.exceptions.TemplateProcessingException:评估 SpringEL 表达式的异常:“#numbers.sequence(0, nubmerOfPage.totalPages-1)”
控制器中的代码:
Page<BatchExecuteHistory> batchExecuteHistory =
batchExecuteHistoryService.getBatchExecuteHistory(id, pageable);
model.addAttribute("jobDetailModel", jobDetailModel);
model.addAttribute("batchExecuteHistory", batchExecuteHistory);
model.addAttribute("nubmerOfPage", batchExecuteHistory.getContent());
model.addAttribute("url", "/jobManagementDetail/{id}/{name}/{time}");
我找到了根本问题:
org.springframework.expression.spel.SpelEvaluationException: EL1008E: 在“java.util.Collections$UnmodifiableRandomAccessList”类型的对象上找不到属性或字段“totalPages” - 可能不公开?
我在此链接中使用代码:Implement paging function with Spring Boot + Thymeleaf
有人知道为什么吗?请帮忙
【问题讨论】:
标签: spring-boot pagination thymeleaf