项目中使用的是bootstrap-table表格展示,为了适用于字段点击排序功能,后端做了动态分页sql拼接
![]()
1.Mybatis动态排序的代码如下
<choose>
<when test=" sortKey != null and sortKey != ''">
order by t1.${sortKey} ${sortType}
</when>
<otherwise>
order by t1.CREATE_TIME desc ,t1.REQ_FIELD_ERROR_COUNT asc
</otherwise>
</choose>
2.如果不启动分页startPage()上述sql执行没问题但是一旦分页,发现执行的sql报错。
3.具体的原因如下:
- startPage()在Controller层会执行分页功能,获取前端的pageNum,pageSize,orderByColumn和isAsc。
/** * 设置请求分页数据 */ protected void startPage() { PageDomain