springboot+thymeleaf+pageHelper带条件分页查询
生活随笔
收集整理的這篇文章主要介紹了
springboot+thymeleaf+pageHelper带条件分页查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
html層
<div><a class="num"><b th:text="'共 '+ ${result.resultMap['pages']}+ ' 頁'"></b></a><a class="num" th:if="${result.resultMap['hasPreviousPage']} == true" th:href="@{'/report/receivePage?currentPage=' + ${result.resultMap['prePage']} + '&sCus=' + ${result.sCus}+ '&sIsPaid=' + ${result.sIsPaid}+ '&start=' + ${result.start}+ '&end=' + ${result.end}}" >上一頁</a><a class="num" th:href="@{'/report/receivePage?currentPage=' + ${result.resultMap['nextPage']}+'&sCus=' + ${result.sCus}+ '&sIsPaid=' + ${result.sIsPaid}+ '&start=' + ${result.start}+ '&end=' + ${result.end}}" th:if="${result.resultMap['hasNextPage']} == true">下一頁</a> </div>controller層
if(!"null".equals(dto.getsCus())){conditionMap.put("sCus",dto.getsCus());}if(dto.getStart() != null && dto.getStart() != ""){// 將時間字符串轉換為時間對象DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");try {conditionMap.put("start",format1.parse(dto.getStart()));} catch (ParseException e) {e.printStackTrace();} }dto
public class ConditionDto {private Integer currentPage=1;private Integer pageSize;private String start;private String end;private String sCus; }?
最近在使用springboot+thymeleaf+pageHelper做帶條件分頁的時候遇到了一些問題,我們在做帶條件查詢分頁的時候,搜索條件需要拼接到url路徑后面,不然翻頁的時候,查詢出來的數據是不帶條件的。但是直接拼接到url后面,所有的數據都會被轉換成String類型,這時,我們需要在controller層做一下判斷與數據類型的轉換。問題暫時解決了,不過代碼還有待優化!
轉載于:https://www.cnblogs.com/pandaQQQ/p/10577038.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的springboot+thymeleaf+pageHelper带条件分页查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: storm无损 the wolven_T
- 下一篇: C语言的C11 标准有哪些改进的地方?C