springMvc分页

@Override

public Pagination<T> queryPagination(Class<T> clazz, Map<String, Object> param, int pageNo, int pageSize) {

List<T> list = queryListResult(SQLCreator.set(clazz, ESQL.QUERYLISTRESULT), param);

long count = queryListResultCount(SQLCreator.set(clazz, ESQL.QUERYLISTRESULTCOUNT), param);

Pagination<T> pageResult = new Pagination<>(list, pageNo, pageSize);

pageResult.setResultSize(count);

return pageResult;

}

<select id="queryListResult" parameterType="map" resultType="SysUser">

select

<include refid="baseColumnList" />

from

SYS_USER_T u

where

u.disabled = 0

<include refid="searchCriteria" />

<include refid="Util.orderCriteria" />

<include refid="Util.mysqlPage" />

</select>

 

<mapper namespace="Util">

<sql id="orderCriteria">

order by 

<if test="orderColumn != null">

${orderColumn}

</if>

<if test="orderColumn == null">

CREATE_TIME

</if>

<if test="orderType != null">

${orderType}

</if>

</sql>

<sql id="mysqlPage">

<if test="pageNo != null and pageSize != null">

limit ${(pageNo - 1) * pageSize}, ${pageSize}

</if>

</sql>

 

</mapper>

你可能感兴趣的:(springMvc分页)