日期:2014-05-18 浏览次数:20804 次
UserInfMapper.xml
<resultMap id="BaseResultMap" type="model.UserInf" >
<id column="user_id" property="userId" jdbcType="DECIMAL" />
<result column="user_name" property="userName" jdbcType="VARCHAR" />
<result column="user_passwd" property="userPasswd" jdbcType="VARCHAR" />
</resultMap>
<select id="findByLimit" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select * from from userInf limit #{start,jdbcType=DECIMAL}
</select>
package com.bing.hrm.common;
/**
* 分页实体
*/
public class PageModel {
/** 默认每页显示的记录条数 */
private static final int PAGE_SIZE = 2;
/** 当前页码 */
private int pageIndex;
/** 每页显示的数量 */
private int pageSize;
/** 总记录条数 */
private int recordCount;
/** setter and getter method */
public int getPageIndex() {
//当前页码不能小于1
this.pageIndex = pageIndex< 1 ? 1 : pageIndex;
//不能大于总页
int totalPage = this.getRecordCount()%this.getPageSize() == 0 ?
this.getRecordCount()/this.getPageSize() :
(this.getRecordCount()/this.getPageSize())+1;
this.pageIndex = this.pageIndex > totalPage ? totalPage : this.pageIndex;
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public int getPageSize() {
return pageSize <= 0 ? PAGE_SIZE : pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getRecordCount() {
return recordCount;
}
public void setRecordCount(int recordCount) {
this.recordCount = recordCount;
}
// limit 第一个?的值
public int getStartRow(){
return (this.getPageIndex() - 1) * this.getPageSize();
}
}