参考即可,不喜勿喷。
<select id="findByPage" resultMap="BaseResultMap" parameterType="Map">
select * from
(select t1.*,rownum rn from
(select * from tableName
//可传入其他条件
<where>
<if test="words!=null">
words like #{words,jdbcType=VARCHAR}
</if>
</where>
) t1
where rownum <= #{currentPage,jdbcType=INTEGER}*#{pageSize,jdbcType=INTEGER}
)
where rn > (#{currentPage,jdbcType=INTEGER}-1)*#{pageSize,jdbcType=INTEGER}
</select>
//调用传入当前页和每页条数即可,如需其他条件也可传入
Map<String, Object> map = new HashMap<String, Object>();
map.put("currentPage", currentPage);
map.put("pageSize", pageSize);
List<Object> list = xxxService.findByPage(map);