Cześć,
piszę paginacje w Spring controllerze, potrzebuje dwóch parametrów Timestamp zeby wyswietic konkretne rekordy, wygląda na to że część backendowa działa dobrze, natomiast mam problem jak to wyświetlić w pliku html ponieważ teraz pojawia się strona 1 a jak kliknę na kolejną to wychodzi IlegalArgumentException - oczekuje Timestamp, a jeśli usune z th:ref argumenty start i end i zostanie same page, to też nie wyświetla mi sie nic a tylko pobiera pusty dokument.
@GetMapping(value = "/getRecordsByPeriod")
public String getRecordsByPeriod(@RequestParam("start") final String start,
@RequestParam("end") final String end,
@PageableDefault(size = 10) final Pageable pageable,
final Model model) {
final Page<FileRecord> page = dbService.getRecordsByPeriod(Timestamp.valueOf(start), Timestamp.valueOf(end), pageable);
model.addAttribute("page", page);
return "recordsByPeriod";
}
<div class="pagination-div">
<span th:if="${page.hasPrevious()}">
<a th:href="@{/getRecordsByPeriod?start=${start}&end=${end}(page=${page.number-1},size=${page.size})}">Previous</a>
</span>
<th:block th:each="i: ${#numbers.sequence(0, page.totalPages - 1)}">
<span th:if="${page.number == i}" class="selected">[[${i}+1]]</span>
<span th:unless="${page.number == i}">
<a th:href="@{/getRecordsByPeriod(start=${start},end=${end},page=${i},size=${page.size})}">[[${i}+1]]</a>
</span>
</th:block>
<span th:if="${page.hasNext()}">
<a th:href="@{/getRecordsByPeriod(start=${start},end=${end},page=${page.number+1},size=${page.size})}">Next</a>
</span>
</div>
Z góry dziękuje za odpowiedz