当前位置: 技术问答>java相关
请问有好的分页实现!
来源: 互联网 发布时间:2015-09-05
本文导语: 上页,下页,直接输入数字, 来者有分!olvest@21cn.com 谢谢! | 看这里,希望对你有帮助! http://www.jspserver.com:8080/cgi-bin/jspbbs/topic.cgi?forum=7&topic=3&show= | 我觉得分页还是在数据...
上页,下页,直接输入数字,
来者有分!olvest@21cn.com
谢谢!
来者有分!olvest@21cn.com
谢谢!
|
看这里,希望对你有帮助!
http://www.jspserver.com:8080/cgi-bin/jspbbs/topic.cgi?forum=7&topic=3&show=
http://www.jspserver.com:8080/cgi-bin/jspbbs/topic.cgi?forum=7&topic=3&show=
|
我觉得分页还是在数据库那头做
写好sql语句,直接把要选记录排序,定位,传出来
看我这句话是否对你有帮助
效率低了点,嘿嘿
写好sql语句,直接把要选记录排序,定位,传出来
看我这句话是否对你有帮助
效率低了点,嘿嘿
|
我做的TableListTag,一直用没问题。代码共享给大家,里面用到了用户身份验证
查询数据库等类,不在这里公开了,根据自己的情况改改就是了。
/*
cxt 2002.8.26
Generate a Table
*/
package com.taglib;
import java.io.IOException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.http.*;
import java.sql.*;
import com.nordsan.tfcrm.UserObject;
import java.util.*;
import java.io.InputStream;
import org.xml.sax.SAXException;
import org.apache.struts.digester.*;
import com.nordsan.tfcrm.util.*;
public final class TableTag extends TagSupport {
private String sqlstatement = ""; //required,SQL String, ex."Select * From Proj_info group by ...."
public String getSqlstatement() { return this.sqlstatement; }
public void setSqlstatement(String sqlstatement) { this.sqlstatement = sqlstatement; }
private String tabletitle = ""; //required,Table Title, ex."title1;title2;title3"
public String getTabletitle() { return this.tabletitle; }
public void setTabletitle(String tabletitle) { this.tabletitle = tabletitle; }
private String haslinenumber = ""; //not required, True(default) or False,If display 序号列
public String getHaslinenumber() { return this.haslinenumber; }
public void setHaslinenumber(String haslinenumber) { this.haslinenumber = haslinenumber; }
private String tablewidth = ""; //not required,Width of the Table, ex. "760"
public String getTablewidth() { return this.tablewidth; }
public void setTablewidth(String tablewidth) { this.tablewidth = tablewidth; }
private String titlealign = ""; //not required,Alignment of the Title(must equals title element number), ex. "Left;;;Right;;"
public String getTitlealign() { return this.titlealign; }
public void setTitlealign(String titlealign) { this.titlealign = titlealign; }
private String columnwidth = ""; //not required,Width of each Column(must equals title element number,exclude linenumber column),ex. "80;150;;;;;"
public String getColumnwidth() { return this.columnwidth; }
public void setColumnwidth(String columnwidth) { this.columnwidth = columnwidth; }
private String columnalign = ""; //not required,Alignment of each Column(must equals title element number), ex. "Left;;;Right;;"
public String getColumnalign() { return this.columnalign; }
public void setColumnalign(String columnalign) { this.columnalign = columnalign; }
private String currentpage = ""; //not required,Define which page to be shown first(default is page 1), ex. "2"
public String getCurrentpage() { return this.currentpage; }
public void setCurrentpage(String currentpage) { this.currentpage = currentpage; }
private String linesperpage = "15"; //not required,Line Number per Page default is 15, ex "20"
public String getLinesperpage() { return this.linesperpage; }
public void setLinesperpage(String linesperpage) { this.linesperpage = linesperpage; }
private String linkcolumn = ""; //not required,Define which Column Used to be the link Col(now you can only set one link col), ex."title1;Project_id;AddProject.jsp"
public String getLinkcolumn() { return this.linkcolumn; }
public void setLinkcolumn(String linkcolumn) { this.linkcolumn = linkcolumn; }
private String operationcolumn = ""; //not required,Define which Column Used to be the operation Col(now you can only set 1 col with max 5 items), ex."title3;Project_id;删除;delete.jsp;添加;add.jsp"
public String getOperationcolumn() { return this.operationcolumn; }
public void setOperationcolumn(String operationcolumn) { this.operationcolumn = operationcolumn; }
public void ReadString(String [] destination, String source, char separator)
{
for (int i = 0,j = 0,StartPosition = 0;i 0)?Integer.parseInt(currentpage):1;
else
CurrentPageNo = (pageContext.getRequest().getParameter("PageNo").length()>0)?Integer.parseInt(pageContext.getRequest().getParameter("PageNo")):1;
if (CurrentPageNo TotalPage)
CurrentPageNo = TotalPage;
int ItemNumber = 1;
for (int i = 0;i 0)
ReadString(TitleAlignment, titlealign, ';');
if (columnwidth.length() > 0)
ReadString(ColumnWidth, columnwidth, ';');
if (columnalign.length() > 0)
ReadString(ColumnAlignment, columnalign, ';');
if (linkcolumn.length() > 0)
ReadString(LinkColumn, linkcolumn, ';');
if (operationcolumn.length() > 0)
{
ItemNumber = 1;
for (int i = 0;i
查询数据库等类,不在这里公开了,根据自己的情况改改就是了。
/*
cxt 2002.8.26
Generate a Table
*/
package com.taglib;
import java.io.IOException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.http.*;
import java.sql.*;
import com.nordsan.tfcrm.UserObject;
import java.util.*;
import java.io.InputStream;
import org.xml.sax.SAXException;
import org.apache.struts.digester.*;
import com.nordsan.tfcrm.util.*;
public final class TableTag extends TagSupport {
private String sqlstatement = ""; //required,SQL String, ex."Select * From Proj_info group by ...."
public String getSqlstatement() { return this.sqlstatement; }
public void setSqlstatement(String sqlstatement) { this.sqlstatement = sqlstatement; }
private String tabletitle = ""; //required,Table Title, ex."title1;title2;title3"
public String getTabletitle() { return this.tabletitle; }
public void setTabletitle(String tabletitle) { this.tabletitle = tabletitle; }
private String haslinenumber = ""; //not required, True(default) or False,If display 序号列
public String getHaslinenumber() { return this.haslinenumber; }
public void setHaslinenumber(String haslinenumber) { this.haslinenumber = haslinenumber; }
private String tablewidth = ""; //not required,Width of the Table, ex. "760"
public String getTablewidth() { return this.tablewidth; }
public void setTablewidth(String tablewidth) { this.tablewidth = tablewidth; }
private String titlealign = ""; //not required,Alignment of the Title(must equals title element number), ex. "Left;;;Right;;"
public String getTitlealign() { return this.titlealign; }
public void setTitlealign(String titlealign) { this.titlealign = titlealign; }
private String columnwidth = ""; //not required,Width of each Column(must equals title element number,exclude linenumber column),ex. "80;150;;;;;"
public String getColumnwidth() { return this.columnwidth; }
public void setColumnwidth(String columnwidth) { this.columnwidth = columnwidth; }
private String columnalign = ""; //not required,Alignment of each Column(must equals title element number), ex. "Left;;;Right;;"
public String getColumnalign() { return this.columnalign; }
public void setColumnalign(String columnalign) { this.columnalign = columnalign; }
private String currentpage = ""; //not required,Define which page to be shown first(default is page 1), ex. "2"
public String getCurrentpage() { return this.currentpage; }
public void setCurrentpage(String currentpage) { this.currentpage = currentpage; }
private String linesperpage = "15"; //not required,Line Number per Page default is 15, ex "20"
public String getLinesperpage() { return this.linesperpage; }
public void setLinesperpage(String linesperpage) { this.linesperpage = linesperpage; }
private String linkcolumn = ""; //not required,Define which Column Used to be the link Col(now you can only set one link col), ex."title1;Project_id;AddProject.jsp"
public String getLinkcolumn() { return this.linkcolumn; }
public void setLinkcolumn(String linkcolumn) { this.linkcolumn = linkcolumn; }
private String operationcolumn = ""; //not required,Define which Column Used to be the operation Col(now you can only set 1 col with max 5 items), ex."title3;Project_id;删除;delete.jsp;添加;add.jsp"
public String getOperationcolumn() { return this.operationcolumn; }
public void setOperationcolumn(String operationcolumn) { this.operationcolumn = operationcolumn; }
public void ReadString(String [] destination, String source, char separator)
{
for (int i = 0,j = 0,StartPosition = 0;i 0)?Integer.parseInt(currentpage):1;
else
CurrentPageNo = (pageContext.getRequest().getParameter("PageNo").length()>0)?Integer.parseInt(pageContext.getRequest().getParameter("PageNo")):1;
if (CurrentPageNo TotalPage)
CurrentPageNo = TotalPage;
int ItemNumber = 1;
for (int i = 0;i 0)
ReadString(TitleAlignment, titlealign, ';');
if (columnwidth.length() > 0)
ReadString(ColumnWidth, columnwidth, ';');
if (columnalign.length() > 0)
ReadString(ColumnAlignment, columnalign, ';');
if (linkcolumn.length() > 0)
ReadString(LinkColumn, linkcolumn, ';');
if (operationcolumn.length() > 0)
{
ItemNumber = 1;
for (int i = 0;i