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层做一下判断与数据类型的转换。问题暂时解决了,不过代码还有待优化!

上一篇:hibernate框架学习第五天:数据查询、投影等


下一篇:基于ubuntu-2.6.35内核的SDIO-WiFi驱动移植