Turn the page display

xiaoxiao2021-03-06  37

Total four solutions

Solve one: Turn the page display, it is DB2, you can change the driver, you can use <% @ page contenttype = "text / html; charSet = GB2312"%> </ title> < / head> <body> <% java.sql.Connection sqlCon; java.sql.Statement sqlStmt; java.sql.ResultSet sqlRst; java.lang.String strCon; java.lang.String strSQL; int intPageSize; int intRowCount; int INTPAGECOUNT; int INTPAGE; Java.lang.String StrPage; INT I, J, K; INTPAGESIZE = 10; strpage = request.getParameter ("page"); if (strpage == null) {INTPAGE = 1;} else {INTPAGE = java.lang.integer.Parseint (strpage); if (INTPAGE <1) INTPAGE = 1;} Class.Forname ("com.ibm.db2.jdbc.app.db2driver"); strcon = "JDBC: DB2: Sample "; sqlcon = java.sql.driverManager.getConnection (strident,", ""); sqlstmt = sqlcon.createstatement (); strsql = "select count (*) from org"; sqlrst = sqlstmt.executeQuery (strsql); sqlRst.next (); intRowCount = sqlRst.getInt (1); sqlRst.close (); intPageCount = (intRowCount intPageSize-1) / intPageSize; if (intPage> intPageCount) intPage = intPageCount; strSQL = "select * from org "; SQLRST = SQLSTMT .ExecuteQuery; i = (intPage-1) * INTPAGESIZE; for (j = 0; j <i; j ) sqlrst.next ();%> <Table Border = "1"> <TR> <TD Colspan = 5 align = center> <% = INTPAGE%> / <% = INTPAGECOUNT%> <% IF (INTPAGE! = 1) {%> <a href="pagedb2.jsp?page=1"> first </A> <%} else {%> first <%}%> <% IF (INTPAGE> 1) {%> <a href="pagedb2.jsp?page=< =intpage 1% "> <<< / a > <%} else {%> <<<</p> <p>%}%> <% IF (INTPAGE <INTPAGECUNT) {%> <a href="pagedb2.jsp?page=<% =intpage 1% >>> </a> <%} else {%>>> > <%}%> <% {%> <a href="pagedb2.jsp?page=< =intpageCount: "> Last </a> <%} else {%> Last <%}%> all <% = introwcount%> ROW </ td> </ tr> <tr> <td> deptnum </ td> <td> deptname </ td> <td> management </ td> <TD > Division </ TD> <TD> Location </ TD> </ Tr> <% i = 0; While (i <intpagesize && sqlrst.next ()) {%> <Tr> <TD> <% = SQLRST. GetString (1)%> </ td> <td> <% = sqlrst.getstring (2)%> </ td> <td> <% = SQLRST.GETSTRING (3)%> </ td> <td> < % = SQLRST.GETSTRING (4)%> </ td> <td> <% = sqlrst.getstring (4)%> </ td> </ tr> <% i ;}%> </ table> <% sqlrst .close (); SQLSTMT.Close (); Sqlcon.close ();%> </ body> </ html> solution 2: Write pactions in Bean! ! ! Give you an example</p> <p>Package com.bbs.bean;</p> <p>Import java.io. *; import java.util. *;</p> <p>Public Class NotelistBean Implements Serializable {</p> <p>private ArrayList noteWriters = new ArrayList (); private ArrayList noteHitNums = new ArrayList (); private ArrayList noteIDs = new ArrayList (); private ArrayList noteTitles = new ArrayList (); private ArrayList notePics = new ArrayList (); private ArrayList noteRewriteNums = new ArrayList (); private arraylist NotelastTimes = new arraylist ();</p> <p>Public NOTELISTBEAN () {}</p> <p>Public int getLength () {return noteids.size ();</p> <p>Public void setnoteids (String Noteid) {Noteids.Add (Noteid);</p> <p>Public String GetNoteids (INT I) {Return (String) Noteids.get (I);} public void setnotepics (String Notepic) {NOTEPICS.ADD (NOTEPIC);</p> <p>Public String GetNotepics (INT I) {Return (String) NOTEPICS.GET (i);</p> <p>Public void setNotewriters (String Notewriter) {Notewriters.Add (Notewriter);</p> <p>Public String GetNotewriters (INT I) {Return (String) Notewriters.get (i);</p> <p>Public void setNotetitles (String NoteTitle) {NOTETLES.ADD (NOTETITLE);</p> <p>Public String GetNotetitles (INT I) {Return (String) Notetitles.get (i);</p> <p>Public void setNoteRewritenums (String NotereWritenum) {NotereWritenums.Add (NotereWritenum);</p> <p>Public String GetNoterewritenums (INT I) {Return (String) Noterewritenums.get (i);</p> <p>Public void setnotehitnums (String Notehitnum) {NotehitNums.Add (NoteHitNum);</p> <p>Public String GetNotehitNums (INT I) {Return (String) Notehitnums.get (i);</p> <p>Public void setNotelaStTimes (String NotlastTime) {NotelyStTimes.Add (NotlastTime);}</p> <p>Public String GetNotelaStility (INT i) {return (string) notlastTimes.get (i);}</p> <p>}</p> <p>Package com.bbs.util;</p> <p>Import java.io. *; import java.util. *; import com.bbs.bean.NotelistBean;</p> <p>Public class pagelist {</p> <p>Private int pageSize = 15; private int recordcount = 0; private int pagePage = 1; private int pageint = 0;</p> <p>NotelistBean Note = New NotelistBean ();</p> <p>Public int getpagesize () {return pagesize;}</p> <p>Public void setRecordcount (int recordcount) {this.recordcount = RecordCount;</p> <p>Public int getRecordcount () {return recordcount;}</p> <p>Public void setPageCount () {this.pagecount = (RecordCount% Pagesize == 0)? (RecordCount / Pagesize) :( Recordcount / PageSize 1);}</p> <p>Public int getPagecount () {return pagecount;}</p> <p>public void setShowPage (String page) {setPageCount (); if (! page = null) {this.showPage = Integer.parseInt (page); if (this.showPage> pageCount) this.showPage = pageCount; else if (this. ShowPage <= 0) this.showpage = 1;} else this.showpage = 1;} public int getShowpage () {Return Showpage;</p> <p>Public void setPageint () {if (RecordCount> 0) this.pageint = (showpage-1) * Pagesize;}</p> <p>Public int getpageint () {setPageint (); return</p> <p>}</p> <p>Solve three: <table width = "760" border = "0" align = "center" cellpadding = "0" cellspacing = "0"> <TR> <TD height = "484" valign = "top"> <a href = "add.jsp"> add </a> <jsp: usebean id = "conbean" scope = "page" class = "beans.dbcon" /> <%! int page = 1; int ROWPANT = 0; int pagecount = 0;%> <% result set = conbean.rs; statement stmt = conbean.stmt; rs = stmt.executeQuery ("SELECT * from user1");%> <% rs.last (); Rowcount = rs.getrow (); pagecount = ((RowCount% PageSize) == 0? (Rowcount / Pagesize) 1);%> <% string topage = request.getParameter ("topage") ; If (Topage! = NULL) {showpage = integer.parseint (Topage); if (showpage> pagecount;} else if (showpage <= 0) {showpage = 1;}}}}}}}}}} = 1;}}}} else = 1;}}}}} = 1;}}}} ShowPage-1) * Pagesize 1);</p> <p>%> <% For (int i = 1; i <= pagesize; i ) {%> <table width = "760" border = "0" align = "center" cellpadding = "0" cellspacing = "0"> < Tr> <td width = "134> <div align =" center "> <% = rs.getstring (1)%> </ div> </ td> <td width =" 302 "> <div align =" Center "> <% = rs.getstring (2)%> </ div> </ td> <td width =" 136> <div align = "center"> <% = rs.getstring (3)%> < / div> </ td> <td width = "94"> <a href="del.jsp?id=< %=rs.getstring (1)%> Delete </a> </ td> <TD Width = "94"> <a href="edit.jsp?id=<%=rs.getstring ("id")% "> Modify </a> </ td> </ tr> </ table> < % IF (! rs.next ()) Break;}%> <% rs.close (); stmt.close ();%> <TD> </ tr> <tr> <TD> <Table Width = " "Border =" 0 "align =" center "cellpadding =" 0 "cellspacing =" 0 "> <tr> <td width =" 1536 "> <div align =" center> </ div> <Table Width = "740" border = "0" align = "center" cellpadding = "0" cellspacing = "0"> <tr> <td width = "469" height = "70"> <div align = "right"> % = PageCount%> / <font C Olor = "# ff0000"> <% =</p> <p>ShowPage%> </ font> page </ div> </ td> <td width = "56"> <div align = "center"> <% IF (showpage! = 1) {%> <a href = index. JSP? Topage = <% = 1% >> Home </a> <%} else {%> <font color = "# cccccc"> Home </ font> <%}%> </ div> </ td> <td width = "49> <div align =" center "> <% if (showpage! = 1) {%> <a href=index.jsp?topage=<% =ShowPage 18> Previous < / a> <font color = "# cccccc"> Previous </ font> <%}%> </ div> </ td> <td width = "54"> <div align = "center"> <% if (showpage! = pagecount) {%> <a href=index.jsp?topage=<% =ShowPage 1%> Next page </a> <%} else {%> <font Color = "# cccccc"> Next page </ font> <%}%> </ div> </ td> <td width = "46"> <div align = "center"> <% IF (showpag) e! = PageCount) {%> <a href=index.jsp?topage=<%=PageCount: "#%> <font color =" # cccccc "> Last page <font color =" # ccccccc "> / font> <%}%> </ div> </ td></p> <p><td width = "66" valign = "bottom"> <div align = "center"> <table width = "99%" border = "0" cellspacing = "0" cellpadding = "0"> <TR> <TD > <form action = index.jsp method = post> <input name = topage type = "text" value = <% = showpage%> size = "4"> page </ form> </ td> </ tr> < / Table> </ div> </ td> </ tr> </ table> </ td> </ tr> </ table> </ td> </ tr> </ table> with me this one. very Simple. Very good ... ^ _ ^</p> <p>Solve four: The brothers upstairs of the Script is very good, but I think the data obtained by the general query is put in Table. If you want to implement the page with JavaScript implementation :), code is still the same, Automatically have a scroll bar in the table. . . . The next example is an example of a boss. I changed it when I used it. I didn't change it. I was very chaotic, huh, huh: <html> <head> <title> main </ title> <style type = text / css > .sort-table {BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: buttonshadow 1px solid; BACKGROUND: window; FONT: Icon; BORDER-LEFT: buttonshadow 1px solid; COLOR: windowtext; BORDER-BOTTOM: buttonshadow 1px solid} .sort-table THEAD {BACKGROUND: buttonface} .sort-table THEAD TD {BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: buttonhighlight 1px solid; BORDER-LEFT: buttonhighlight 1px solid; CURSOR: default; BORDER-BOTTOM: buttonshadow 1px solid} .sort-table TBODY TD {BORDER-RIGHT: buttonshadow 1px solid; BORDER-TOP: buttonhighlight 1px solid; BORDER-LEFT: buttonhighlight 1px solid; CURSOR: default; BORDER-BOTTOM: buttonshadow 1px solid} </ STYLE> <script language = "javascript"> function fixTable () {for (var i = 0; i <maintablehead.rows [0] .Cells.Length; i ) {if (maintablehead.rows [0] .Cells [i]. OffsetWidth> Eval ("COL" i) .offSetWidth) {EVAL ("COL" i) .Style.Width = MainTable Head.ROWS [0] .cells [i] .offsetwidth-10} else {maintablehead.rows [0] .cells [i] .style.Width = EVAL ("col" i) .offSetWidth-10}}} mainTableHead.offsetWidth> mainTableBody.offsetWidth) {mainTableBody.style.width = mainTableHead.offsetWidth} else {mainTableHead.width = mainTableBody.offsetWidth} Layer1.style.width = Layer1.scrollWidth 16 Layer1.style.height = document.body. ClientHeight - Layer1.offSettop</p> <p>Window.attachevent ("OnResize", New Function ("FixTable ()")) WINDOW.ATTACHEVENT ("OnLoad", New Function ("FixTable ()")) </ script> </ head> </ head> < Table class = sort-table cellspacing = 0 cellpadding = 4 id = maintablehead> <THEAD> <triple = "mainhead" align = "middle"> <TD NOWRAP> Permissions </ td> <TD NOWRAP> Table / Operation < / TD> </ tr> </ thead> </ table> <div id = layer1 style = "z-index: 1; overflow: auto; position: absolute; height = 300> <table class = sort-table cellspacing = 0 Cellpadding = 4 id = "maintablebody"> <colgroup> <col id = "colGroup> <col id =" col1 "> </ colgroup> <tbody> <tr> <td nowrap width =" 60 "> < Input type = "checkbox" name = "c1" value = "on"> </ td> <TD NOWRAP> table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table table Table table table </ td></p> <p></ Tr> <tr> <TD NOWRAP WIDTH = "60> <input type =" checkbox "name =" c2 "value =" on "> </ td> <td noWrap> 13 </ td> </ tr > <Tr> <TD NOWRAP WIDTH = "60> <input type =" checkbox "name =" c3 "value =" on "> </ td> <td nowrap> 13 </ td> <TR> <TR > <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = "c4" value = "on"> </ td> <TD NOWRAP> 13 </ TD> </ TR> <TR> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = "c5" value = "on"> </ td> <TD NOWRAP> 13 <TD> </ TD> <TR> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = "c7" value = "on"> </ td> <tr> <tr> <td nowrap width = "60" > <input type = "checkbox" name = "c6" value = "on"> </ td> <td number = "<TD> </ tr> <tr> <TD NOWRAP WIDTH =" 60 "> <input Type = "checkbox" name = "c8" value = "on"> </ td> <TD NOWRAP> 13 <TD> </ TD> <Tr> <TD NOWRAP WIDTH = "60"> <Input Type = " Checkbox "name =" c9 "value =" on "> </ td> <TD NOWRAP> 13 </ td> </ tr> <TR> <</p> <p>TD NOWRAP Width = "60"> <input type = "checkbox" name = "c10" value = "on"> </ td> <td number 13> 13 </ td> <TR> <Tr> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = "c11" value = "on"> </ td> <td number = "</ td> <tr> <tr> <td nowrap width =" 60 "> <input type =" checkbox "name =" c12 "value =" on "> </ td> <TD NOWRAP> 13 <TD> </ tr> <tr> <TD NOWRAP WIDTH =" 60 "> < INPUT TYPE = "CheckBox" name = "c13" value = "on"> </ td> <TD NOWRAP> 13 <TD> </ tr> <tr> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = "c14" value = "on"> </ td> <TD NOWRAP> 13 <TD> </ TD> <Tr> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" Name = "c15" value = "on"> </ td> <TD NOWRAP> 13 <TD> </ tr> <tr> <TD NOWRAP WIDTH = "60"> <input type = "checkbox" name = " C16 "Value =" on "> </ td> <TD NOWRAP> 13 <TD> </ tr> <tr> <TD NOWRAP WIDTH =" 60 "> </ TD> <TD NOWRAP> 13 </ TD> </ TR> <TR> <TD NOWRAP Width = "60"> </ td> <TD NOWRAP> 13 </ TD> </ TR> <TR> <</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-64517.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="64517" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.106</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'B2sg9GrobolqBqLD6M2_2BHOPCjpmzsgrPY0QXEvoLe6ictk_2BjGWnhEKsHpuVhSJs_2FLFGtumdL6bW7aLq3_2BJ8EyQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>