1.页面处理:
列表<table>元素下方:
<div align="right" style="height: 20px; font-size:12px; margin-top: 5px; padding-bottom: 0px;display: block;">
共 <#resultSize> 条记录 每页 <#pageSize> 条 <#first>  | <#pageUp>  |  <#pageDown>  |  <#last> 第 <#pageIndex> 页 / 共 <#pageCount> 页
</div>
<!-- 当前页 -->
<input type="hidden" name="pageIndex" value="<#pageIndex>"/>
2.页面js方法:
//页码跳转(发送请求)
function pageTurn(pageIndex){
var frmMain = document.getElementsByName("frmMain")[0];
frmMain.cmd.value="TBS_INVOICE_RECEIVE_LIST";
frmMain.pageIndex.value=pageIndex;
getParams('frmMain');
frmMain.target="_self";
frmMain.submit();
return false;
}
3.java类中参数的接收处理:
else if("TBS_INVOICE_RECEIVE_LIST".equals(socketCmd)){//到款开票列表界面
String init = myCmdArray.elementAt(3).toString();
String params = UtilCode.decode(myStr.matchValue("_parameters[", "]parameters_"));
Hashtable hash = FormParametersUtil.getParameters(params);
myOut.write(iaw.getInvoiceReceiveList(hash));
iaw = null;
}
public String getInvoiceReceiveList(Hashtable hash){
String where = "";
........//where 查询条件的拼接
//分页
int pageIndex=DaoUtil.nullToNumber2(hash.get("pageIndex"));//第几页 --从0开始
pageIndex=pageIndex==0?1:DaoUtil.nullToNumber2(hash.get("pageIndex"));
int pageSize=2;//每页几条
int resultSize=0;//总共多少条
int pageCount=0;//共几页
String first="";//首页
String pageUp="";//上一页
String pageDown="";//下一页
String last="";//末页
try{
//分页的逻辑处理
resultSize=DBSql.getInt(conn,"select count(1) count from tbs_next_invoicing where 1=1 "+where+" ", "count");
pageCount=resultSize%pageSize==0?(resultSize/pageSize):(resultSize/pageSize+1);
first=pageIndex==1?"首页":"<a href='javascript:pageTurn(0);' style='color: blue;text-decoration:none;'>首页</a>";
pageUp=pageIndex==1?"上一页":"<a href='javascript:pageTurn("+(pageIndex-1)+");' style='color: blue;text-decoration:none;'>上一页</a>";
pageDown=pageIndex==pageCount||pageCount==0?"下一页":"<a href='javascript:pageTurn("+(pageIndex+1)+");' style='color: blue;text-decoration:none;'>下一页</a>";
last=pageIndex==pageCount||pageCount==0?"末页":"<a href='javascript:pageTurn("+pageCount+");' style='color: blue;text-decoration:none;'>末页</a>";
//分页的sql语句
String sql = "select * from (select m.*, rownum rn from (select * from tbs_next_invoicing where 1=1 "
+ ""+where+" order by createtime desc) m where rownum <= "+pageSize*pageIndex+") a where a.rn > "+pageSize*(pageIndex-1);
List list = DaoUtil.getData(conn, sql);
Hashtable ht = new Hashtable();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
ht = (Hashtable) list.get(i);
.........//拼接列表界面
}
}
}
}catch(Exception e){
e.printStackTrace();
}finally{
DBSql.close(conn, null, null);
}
hashTags.put("pageIndex",pageIndex);
hashTags.put("pageSize",pageSize);
hashTags.put("resultSize", resultSize);
hashTags.put("pageCount",pageCount);
hashTags.put("first", first);
hashTags.put("pageUp", pageUp);
hashTags.put("pageDown", pageDown);
hashTags.put("last", last);
return RepleaseKey.replace(HtmlModelFactory.getFile("../template/eform/html/invoice/tbs_eform_invoice_receive_list.html"), hashTags);
}