实体
import java.util.ArrayList;import java.util.List;
public class PageVo<T> {
private static final long serialVersionUID = 1L;
/**
* 总条数
*/
private int totalCount = 0;
/**
* 当前页
*/
private int currentPage = 0;
/**
* 每页数据条数
*/
private int pageSize = 10;
public List<T> list=new ArrayList<T>();
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return (totalCount - 1) / pageSize + 1;
}
}
mapping.xml
<!-- 分页 -->
<resultMap id="PageInfoResultMap" type="com.ssm.common.PageInfo" >
<result column="totalCount" property="totalCount" jdbcType="INTEGER"/>
<result column="currentPage" property="currentPage" jdbcType="INTEGER"/>
<result column="pageSize" property="pageSize" jdbcType="INTEGER"/>
</resultMap>
<!-- 分页查询 1-->
<select id="findPageListBySQL" resultType="com.ssm.vo.Purchaserecord_user_vo" parameterType="com.ssm.vo.Purchaserecord_user_vo">
SELECT purchaserecord.*,user.uname FROM purchaserecord INNER JOIN USER ON purchaserecord.uid= user.uid
WHERE 1=1
<if test="uid !=null and uid !=0">
and purchaserecord.uid=#{uid,jdbcType=INTEGER}
</if>
<if test="purchaseone !=null and purchaseone !=''">
and purchaserecord.purchaseOne=#{purchaseone,jdbcType=INTEGER}
</if>
<if test="currentPage==1">
limit 0, #{pageSize,jdbcType=INTEGER}
</if>
<if test="currentPage>1">
limit ${(currentPage-1)*pageSize},${pageSize}
</if>
</select>
<!-- 分页属性数据 1-->
<select id="findPageInfoBySQL" resultMap="PageInfoResultMap">
select
count(purchaseRecordid) as totalCount,#{pageSize,jdbcType=INTEGER} as pageSize,#{currentPage,jdbcType=INTEGER} as currentPage,
purchaserecord.*,user.uname FROM purchaserecord INNER JOIN U