Simple and easy to use pagination label

xiaoxiao2021-03-06  44

I used some tags that I didn't use much. I didn't save much strength. I learned that I wrote one of my own labels. I feel ok. The following is the example: _ _CURPAGE_PPAG _PageCount_ page A total _Recordcount _ 条 Sequence No. Title Start Time End Time Moderator Location & _no _ _2 _ _3 _ _4 _ _6 _ < TD> _5 _ & tag.javaimport javax.servlet.jsp. *; import javax.servlet.jsp.tagext.tagsupport; import javax.servlet.jsp .tagext.bodytagsupport;

public class Tag extends BodyTagSupport {private String sql; public int doStartTag () {return this.EVAL_BODY_BUFFERED;} public void setSql (String arg) {this.sql = arg;} String field; public void setField (String arg) {this. field = arg;} public int intPageIndex; private void initParameter (javax.servlet.ServletRequest request) {try {String pageindex = request.getParameter ( "emPageIndex"); pageindex = pageindex == null || pageindex.equals ( "_ emPageIndex_" )? "0": PageIndex; INTPAGEINDEX = INTEGER.PARSEINT (PageIndex); if (Request.getParameter ("first")! = Null) INTPAGEINDEX = 0; Else IF (Request.GetParameter ("Piror")! = NULL) intPageIndex = intPageIndex-1; (! request.getParameter ( "next") = null) else if intPageIndex = intPageIndex 1; else if (! request.getParameter ( "last") = null) intPageIndex = 100000;} catch (Exception EX) {INTPAGEINDEX = 0;}

Public int doendtag () throws javax.servlet.jsp.jspexception {TRY {initParameter (this.pagecontext.getRequest ()); string body = this.getBodyContent (). GetString ();

String navigation = body.substring (0, body.indexof (" &") - 1); String Data = body.substring (Body.indexof (" &") 5, body.indexof (" & "); string tail = body.substring (Body.indexof (" & ") 6, body.length ());

Pagination page = new Pagination (sql, intPageIndex); sun.jdbc.rowset.CachedRowSet rowset = page.getRcord (); String field; navigation = navigation.replaceAll ( "_curpage_", (page.getPageIndex () 1) " "); Navigation = navigation.replaceAll (" _PAGECUNT_ ", ()" "" "; navigation = navigation.replaceAll (" _RecordCount_ ", (page.getRecordCount ()) " ""; navigation = navigation .replaceAll ("_empageindex_", ()) "" "; this.pageContext.get (). Write (navigation); if (RowSet! = null) {string Temp; for (int J = 1; RowSet.next (); pageContext.get (). Write (" / n" temp " / n"), J ) {TEMP = Data; Temp = Temp.ReplaceAll ("_ NO_" , J ""); int size = rowset.getMetadata (). getColumnCount (); for (int i = 1; i <= size; i ) {TEMP = Temp.Replaceall ("_" i "_", com.sinosoft.util.tool.jutilities.getstring (rowset, i));}}} t His.pageContext.get (). Write (tail);} catch (exception e) {// throw new JSPEXCEPTION ("IO Error:" E.GetMessage ()); E.PrintStackTrace ();} returnval_page;}

}

转载请注明原文地址:https://www.9cbs.com/read-75223.html

New Post(0)