1、jsp实现JSON分页显示ACTION:public String teamInsure() /String grpcode = getRequestParameter(grpcode); / 团体代码 String grpcode = CHS000G01944; log.info(grpcode:+grpcode+团体投保信息-); List teamInsureList = new ArrayList(); Pager pager = getPager(classDetailInfo/classDetailInfo_teamInsure.do?page=); pager.setPagesi
2、ze(3); PageText pageText = null; try teamInsureList = classDetailInfoServices.getTeamInsure(grpcode); pageText = classDetailInfoServices.getPageText(teamInsureList, pager, teamInsureList.size(); JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); for (int i = 0; i teamIn
3、sureList.size(); i+) jsonObject.element(gappno, (teamInsureList.get(i).getGappno(); jsonObject.element(gpolicyno, (teamInsureList.get(i).getGpolicyno(); jsonObject.element(classcode, (teamInsureList.get(i).getClasscode(); jsonObject.element(size, (teamInsureList.size(); jsonObject.element(pagecount,
4、 (teamInsureList.size() + 2) / 3); String classcode = (teamInsureList.get(i).getClasscode(); if (!FunctionUtils.isBlank(classcode) String classname = classDetailInfoServices.getClassname(classcode); / 险种名称 jsonObject.element(classname, classname); else jsonObject.element(classname, ); jsonObject.ele
5、ment(polist, (teamInsureList.get(i).getPolist(); jsonObject.element(stat, (teamInsureList.get(i).getStat(); jsonObject.element(sumamt, (teamInsureList.get(i).getSumamt(); jsonObject.element(illamt, (teamInsureList.get(i).getIllamt(); jsonObject.element(accamt, (teamInsureList.get(i).getAccamt(); jso
6、nObject.element(sickamt, (teamInsureList.get(i).getSickamt(); jsonObject.element(medamt, (teamInsureList.get(i).getMedamt(); jsonObject.element(tmount, (teamInsureList.get(i).getTmount(); jsonObject.element(sappdate, (teamInsureList.get(i).getSappdate(); jsonObject.element(allnum, (teamInsureList.ge
7、t(i).getAllnum(); jsonObject.element(size, (teamInsureList.size(); jsonObject.element(pagecount, (teamInsureList.size() + 2) / 3); jsonArray.add(jsonObject); response.setContentType(text/html); response.setCharacterEncoding(GB2312); PrintWriter out = response.getWriter(); String json = jsonArray.toS
8、tring(); log.info(json); out.write(json); out.flush(); out.close(); catch (Exception e) setRequestAttribute(msgInfo, 获取团体投保信息失败,请稍后再试); setRequestAttribute(techInfo, 调用交易1216015返回失败); e.printStackTrace(); log.info(e); return error; return null; #分页实现方法: (可以不使用,进攻参考)package com.cpic.hbtx.util;import
9、java.util.ArrayList;import java.util.List;import com.cpic.hbhp.util.Pager;public class PageText private int nowpage = 1; / 当前页数 private int pagesize; / 每页显示行数 private int startrow; / 开始分页行数 private int allnum; / 总记录数 private int pagecount; / 总页数 private String path; / 链接路径 private String pageText; /
10、 页面显示 private List objlist = new ArrayList(); / 分页对象 public List getObjlist() return objlist; public void setObjlist(List objlist) this.objlist = objlist; public PageText(List list, Pager pager, int allnum) throws Exception / 路径 this.path = pager.getPath(); / 总记录数 this.allnum = allnum; / 每页显示行数 this
11、.pagesize = pager.getPagesize(); / 当前页数 this.nowpage = pager.getPage(); / 总页数 this.pagecount = (this.allnum + this.pagesize - 1) / this.pagesize; / 开始分页行数 this.startrow = this.nowpage * this.pagesize; objlist = getList(list, startrow, pagesize, pagecount, nowpage); getPageText(); /* * 分页对象 */ Suppre
12、ssWarnings(unchecked) public List getList(List list, int startrow, int pagesize,int pagecount,int nowpage) if (pagecount = nowpage) for (int i = (startrow - pagesize);i list.size();i +) this.objlist.add(list.get(i); else for (int i = (startrow - pagesize);i startrow;i +) this.objlist.add(list.get(i)
13、; return this.objlist; /* * 页面显示信息 */ public String getPageText() try if (this.allnum != 0) this.pageText = 共【 + this.allnum + 】条记录 每页显示 + this.pagesize + 条记录 共【 + this.pagecount + 】页 当前第 + this.nowpage + 页 ; if (this.nowpage = 1) else this.pageText += 首 页 thi
14、s.pageText += 上 一 页 if (this.nowpage = this.pagecount) else this.pageText += 下 一 页 this.pageText += 尾 页 this.pageText += 跳到第; this.pageText += function inPage() var reg = /d+$/; + var pageno=document.getElementById(pageno).value; + if(!reg.test(pageno) | parseInt(pageno) + this.pa
15、gecount + )alert(输入的页数超过了总页数,请重新输入);return false; elsewindow.location.href= + this.path + +pageno;return true; + ; this.pageText += ; this.pageText += 页; this.pageText += ; else this.pageText = 未查询到数据 ! ; catch (Exception e) e.printStackTrace(); return this.pageText; #JSP: base href= var temp = null
16、; function inPage() var tr = ; var reg = /d+$/; var pageno=parseInt($(#pagenotest).val(); var startrow = pageno * 3; var pagecount2 = parseInt($(#pagecount2).text(); if(!reg.test(pageno) | parseInt(pageno) pagecount2) alert(输入的页数超过了总页数,请重新输入); return false; else if(pagecount2 = pageno) for(var j = (
17、startrow - 3);j temp.length;j +) var gappno = tempj.gappno; var gpolicyno = tempj.gpolicyno; var classcode = tempj.classcode; var classname = tempj.classname; var polist = tempj.polist; var stat = tempj.stat; var illamt = tempj.illamt; var accamt = tempj.accamt; var sickamt = tempj.sickamt; var meda
18、mt = tempj.medamt; var tmount = tempj.tmount; var sappdate = tempj.sappdate; var allnum = tempj.allnum; tr = tr+ +gappno+ +gpolicyno+ +classcode+ +classname+ +polist+ +stat+ +illamt+ +accamt+ +sickamt+ +medamt+ +tmount+ +sappdate+ +allnum+ ; else for(var j = (startrow - 3);j startrow;j +) var gappno
19、 = tempj.gappno; var gpolicyno = tempj.gpolicyno; var classcode = tempj.classcode; var classname = tempj.classname; var polist = tempj.polist; var stat = tempj.stat; var illamt = tempj.illamt; var accamt = tempj.accamt; var sickamt = tempj.sickamt; var medamt = tempj.medamt; var tmount = tempj.tmoun
20、t; var sappdate = tempj.sappdate; var allnum = tempj.allnum; tr = tr+ +gappno+ +gpolicyno+ +classcode+ +classname+ +polist+ +stat+ +illamt+ +accamt+ +sickamt+ +medamt+ +tmount+ +sappdate+ +allnum+ ; $(#currpage).html(pageno); $(#test1).html(tr); function initview() showIframe();/初始化页面处理方法 /tab页 var tabID = new Array(team,person); var tableIDs= new Array(teamTable,personTable); setTabId(tabID,tableIDs); function s
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1