mysql分页查询,从0开始 向前台传递json数据 后台定义返回Map
<select id="selectByPage" resultType="Chapter">
select *
from cmfz_chapter where album_id=#{albumId} limit #{start},#{rows}
</select>
<select id="getCount" resultType="Integer">
select count(id) from cmfz_chapter where album_id=#{albumId}
</select>
Map<String, Object> map = new HashMap<>();
Integer records = chapterDao.getCount(albumId);
Integer total=records%rows==0 ? records/rows : records/rows+1;
Integer start=(page-1)*rows;
List<Chapter> carousels = chapterDao.selectByPage(start, rows, albumId);
map.put("total",total);
map.put("records",records);
map.put("page",page);
map.put("rows",carousels);
return map;
716

被折叠的 条评论
为什么被折叠?



