1.ibatis配置:list集合查询

select ID, NAME, NOTE, POLICIES, SN, MODIFY_DATE, SYS      from USER_OA.T_RES_ROLE      where ID = #id:VARCHAR#  


2.Dao配置:

public List selectUsersByServId(String servId, int pageNum,  			int pageSize) throws SQLException {  		// TODO Auto-generated method stub  		List list = sqlMapClient.queryForList(  				"P4_01.selectUsersByServId",  				servId, pageNum, pageSize);  		return list;  	}  


3.分页类(SplitPageForm)

public class SplitPageForm {  	/*  	 * 当前页号  	 */  	private String pageNum = null;    	/*  	 * 每页显示条数  	 */  	private String pageSize = "8";    	/*  	 * 总记录数  	 */  	private String rowCount = null;    	public int getPageCount() {  		int pageCount=(getRowCount() + getPageSize() - 1) / getPageSize();  		if(pageCount==0){pageCount=1;}  		return pageCount;  	}  	public int getPageNum() {  		if (pageNum == null) {		pageNum = "1";  		}  		return Integer.valueOf(pageNum);  	}  	public void setPageNum(String pageNum) {  		this.pageNum = pageNum;  	}  	public int getPageSize() {  		if (pageSize == null) {  			pageSize = "8";  		}  		return Integer.valueOf(pageSize);  	}  	public int getRowCount() {  		if (rowCount == null) {  			rowCount = "0";  		}  		return Integer.valueOf(rowCount);  	}  	public void setRowCount(String rowCount) {  		this.rowCount = rowCount;  	}    	public int getStartRowNum() {  		return (getPageNum() - 1) * getPageSize();  	}  }  
  
  

4.Form设置将属性包装成Form类,继承分页类SplitPageForm。5.Action设置

String count = String.valueOf(dao.countInfo());// 得到总数    form.setRowCount(count);// 设置总记录数    List<TResDict> dictList = dao.selectInfoByExample(example, form  					.getStartRowNum(), form.getPageSize());    form.setDictList(dictList);  

6.JS配置

function prePage() {  	var p = parseInt(document.getElementById("form.pageNum").value);  	p = p - 1;
if (p < 1) {  		p = 1;  	}  	document.getElementById("form.pageNum").value = p;  	document.all.queryFrm.submit();  }    function nextPage() {  	var p = parseInt(document.getElementById("form.pageNum").value);  	var max = parseInt(document.getElementById("form.pageCount").value)  	p = p + 1;  	if (p > max) {  		p = max;  	}  	document.getElementById("form.pageNum").value = p;  	document.all.queryFrm.submit();  }    function firstPage() {  	document.getElementById("form.pageNum").value = 1;  	document.all.queryFrm.submit();  }    function lastPage() {  	var max = parseInt(document.getElementById("form.pageCount").value)  	document.getElementById("form.pageNum").value = max;  	document.all.queryFrm.submit();  }  

  

7.jsp页面设置

在循环的末尾加入:

<div  style="height:25px; margin-top:10px;">  	<table border="0" style="width: 97%; font-size:13px; margin-top:10px;">      	<tfoot>  		 <tr align="right">  		 	<td>         		<s:form id="queryFrm" action="p3_03_01.do" method="post">  				<s:hidden name="form.pageNum" id="form.pageNum" />    				<s:hidden name="form.pageCount" id="form.pageCount" />    				<s:hidden name="type" id="type" />                  <%@include file="../page.jsp" %>                   </s:form>                  </td>               </tr>               		</tfoot>  	</table>  </div>