Taglib Query Perpage

zhaozj2021-02-16  58

<% @ Page ContentType = "Text / HTML; Charset = UTF-8" Language = "Java"%> <% @ Taglib URI = "/ Struts-bean" prefix = "bean"%> <% @ Taglib URI = " / struts-html "prefix =" html "%> </ title> <html: base /> </ head> <body bgcolor =" white> <html: errors / > <html: form action = "/ query"> <table border = "1" width = "100%"> <logic: Itereate ID = "queryResult" name = "queryResult"> <tr> <TD align = "Left "> <Bean: write name =" queryResult "property =" code "filter =" true "/> </ td> <td align =" left "> <bean: write name =" queryResult "property =" name "Filter = "true" /> </ td> <td align = "center"> <bean: write name = "queryResult" property = "CODETYPE" filter = "true" /> </ td> <! - <td align = "center"> <app: linkSubscription page = "/ editSubscription.do?action=Delete"> <bean: message key = "registration.deleteSubscription" /> </ app: linkSubscription> <app: linkSubscription page = "/ editSubscription .do? Action = Edit> <bean: message key = "registration.editsubscription" /> </ app: linksu BSCRiption> </ td> -> </ tr> </ logic: Iterate></p> <p></ TABLE></p> <p></ html: form> </ html: html> // **************************************************** // ******************************************* Package com.wellhope.commons;</p> <p>import java.io.IOException; import java.util.Locale; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org .apache.struts.action.action; import org.apache.struts.action.Apache.Arror; import org.apache.struts.action.Apache.struts.Act Org.Apache.Struts.Act Org.Apache.Struts.Action .ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.util.MessageResources; import com.wellhope.commons.QueryresultForm; import com.wellhope. Base.log;</p> <p>Public class queryResultAction extends action {public queryResultAction () {}</p> <p>public ActionForward perform (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {System.out.println ( "has enter into QueryresultAction"); Log log = new Log (QueryresultAction.class); Locale locale = getLocale (request); MessageResources messages = getResources (request); HttpSession session = request.getSession (); String pagenumber = request.getParameter ( "pagenumber"); if (pagenumber == null || pagenumber.equals ( "")) { Pagenumber = "1";} if (form == null) {form = new queryResultform (); if ("request" .Equals (mapping.getscope ()) {request.getattribute () (mapping.getattribute () (), Form) } Else {session.setttribute (mapping.getattribute ();}}}}}}}}}}}}}} queryResultform) Form; Qf.SetPagenumber (Integer.Valueof (PAGENUMBER) .Intv Alue ()); Qf.GetQueryResult (); // PropertyUtils.copyProperties (Subform, subscription); // SaveToken (Request); return mapping.findforward ("Success");}} / package com.wellhope.commons;</p> <p>import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.HashMap; import com.wellhope.commons.Constants; import com.wellhope.commons.table.Sys_Code; import net .sf.hibernate.query; import net.sf.hibernate.Session; import net.sf.hibernate.Transaction; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.cfg.configuration; import net.sf. hibernate.MappingException; import net.sf.hibernate.HibernateException; import org.apache.struts.action *;. import com.wellhope.commons.QueryresultBean; public class QueryresultForm extends ActionForm {public QueryresultForm () {}</p> <p>Private arrayList queryResult = null; private int pageize = 0; file: // Make each page show private int count = 0; file: / / How many record private int Pagenumber = 0; file: // is currently the first A number of pages of private int potes = 0; file: / / How many pages of a total of a total of a total of the records per page Public void setpagesize (int pagesize) {this.pageSize = pagesize;}</p> <p>Public int getpagesize () {return this.pageSize;</p> <p>File: // Total record number public void setcounts (int counts) {this.counts = counts;}</p> <p>Public int getcounts () {return this.counts;} file: // Total number PUBLIC VOID SetPages (int pages) {this.pages = pages;</p> <p>Public int getpages () {returnid.</p> <p>File: // Current page number public void setpagenumber (int Pagenumber) {this.pagenumber = Pagenumber;}</p> <p>Public int getpagenumber () {ix (this.pagenumber> this.pages && this.pagenumber> 1) {this.pagenumber = this.pages;} Return this.pagenumber;</p> <p>Public void setQueryResult (arraylist al) {this.queryResult = al;}</p> <p>Public arraylist getQueryResult () {return this.queryResult;}</p> <p>Public int getStartIndex () {return (this.pagenumber - 1) * this.pagesize;</p> <p>Public int getAllPages () {return this.counts% this.pageSize == 0? this.counts / this.pageSize: this.counts / this.pageSize 1;} public void getQueryResult () {system.out.println (" has enter into QueryresultForm "); setPagesize (Constants.DEFAULTPAGESIZE); try {// Sys_Code sc = new Sys_Code (); Configuration cf = new Configuration () addClass (Sys_Code.class);. SessionFactory sf = cf.buildSessionFactory (); Session session = sf.openSession (); file: // Total number of records query querycounts = session.createQuery ("Select count (*) from sys_code as sc"); list querylist = querycounts.list (); if (querylist) .isempty ()) {setcounts (0); setpages (0);} else {setcounts (qerylist.get (0) .tostring ()); setAllPages ());} Query query = session.createQuery ("from sys_code as sc"); file: // Set the query query query.setfirstResult (getStartIndex ()) from the proprietary record; file: // set once How many records of query query record Query.SetMaxResults (getPagesize ()); list list = query.list ();</p> <p>IF (! list.iserpty ()) {this.queryResult = new arraylist (); arraylist midal = (arraylist) list; for (int i = 0; i <midal.size (); i ) {sys_code syscode = (sys_code ) Midal.get (i); havehmap hm = new hashMap (); queryResultbean QB = new queryResultBean (); qb.setcode (syscode.getcode ()); qb.setname (syscode.getname ()); qb.setcodetype Syscode.getcode_type ()); hm.put (syscode.getcode (), qb);</p> <p>THIS.QUERYRESULT.ADD (HM); // ArrayList Tempal = (arraylist) list; // tempal.add (syscode.getcode ()); // Tempal.Add (Syscode.GetName ()); // Tempal.Add (syscode.getcode_type ()); // tempal.add (syscode.getcomments ()); // this.queryResult.add (tempal);}} session.close ();} catch (exception ex) {EX.PrintStackTrace ();} System.out.println ("Result is:" this.QueryResult);}} // <? XML Version = "1.0" encoding = "ISO-8859-1"?> <! Doctype struts-config Public "- // Apache Software Foundation // DTD Struts Configuration 1.1 // en" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config></p> <p><form-beans> <form-bean name = "queryResultform" type = "com.wellhope.commons.queryResultform" /> <form-bean name = "registerform" type = "com.wellhope.learn.test2.registerform" / > <Form-bean name = "logonform" type = "com.wellhope.learn.test2.logonform" /> </ form-beans></p> <p><global-forwards> <forward name = "welcome" path = "/ pages / welcome.jsp" /> <forward name = "logon" path = "/ pages / logon.jsp" /> <forward name = "register" Path = "/ page / register.jsp" /> <forward name = "logoff" path = "/ logoff.do" /> <forward name = "query" path = "/ query.do" /> </ global- Forwards></p> <p><action-mapings> <! type = "/ welcome.do" parameter = "pages / welcome.jsp" /></p> <p><action path = "/ logon" type = "/ logon.do" parameter = "pages / logon.jsp" /> -> <action path = "/ logoff" type = "com.wellhope.learn.test2.logoffaction "/> <action path =" / logonsubmit "Type =" com.wellhope.learn.test2.logonaction "name =" logonform "scope =" request "validate =" true "infut =" pages / logon.jsp "> < Forward name = "welcome" path = "/ pages / welcome.jsp" /> <forward name = "failure" path = "/ pages / logon.jsp" /> </ action> <action path = "/ query" TYPE = "com.wellhope.commons.QueryResultAction" name = "queryResultform"> <forward name = "access" path = "/ pages / test.jsp" /> <forward name = "Failure" Path = "/ pages / failure. HTML "/> </ action> <action path =" / register "type =" com.wellhope.learn.test2.register "name =" registerform "> <forward name =" access "path =" / pages / surcess. HTML "/> <forward name =" failure "Path =" / Pages / Failure.html "/> </ action> </ action-mapings></p> <p><! - ==========Message resources definitions ============================ -> <message Resources parameter = "com.wellhope.commons.ApplicationResources" /></p> <p><! - </ message-resources> -> </ struts-config> /</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-20357.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="20357" 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.040</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 = 'AW7D06wguJl0ZUZWxngpZw8KIXpP2AloFvNpRD9pjZ0PR22pJ_2B42d3fBWJcMLKLHKzNBwIdc75YrmkktIdlLmw_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>