当前位置: 技术问答>java相关
谁给一个在bean中分页取数据,然后把数据放到arraylist里,然后在页面中调用的例子我就给出100,决不失言!
来源: 互联网 发布时间:2015-08-13
本文导语: 谁给一个在bean中分页取数据,然后把数据放到arraylist里,然后在页面中调用的例子我就给出100,决不失言! | 我这有段mysql的,但是没有放到数组里,直接返回的是resultset,不知你用不用的上? pack...
谁给一个在bean中分页取数据,然后把数据放到arraylist里,然后在页面中调用的例子我就给出100,决不失言!
|
我这有段mysql的,但是没有放到数组里,直接返回的是resultset,不知你用不用的上?
package KWT;
import javax.servlet.*;
//import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class MyPage{
/*
public JspWriter out=null;
private void print(String str) throws ServletException{
try{
out.print(str);
}catch(java.io.IOException e){
throw new ServletException(e);
}
}
*/
private int m_iSize=0;
private String m_sFields=null;
private String m_sFilter=null;
private String m_sTable=null;
private String m_sOrder=null;
private int m_iCurrentNo=0;
private Connection m_oConn=null;
private int m_iCount=0;
private int m_iTotal=0;
private int m_iBegin=0;
private int m_iEnd=0;
public void setSize(int iSize){
m_iSize=iSize;
}
public void setFields(String sFields){
m_sFields=sFields;
}
public void setWhere(String sFilter){
m_sFilter=sFilter;
}
public void setTable(String sTable){
m_sTable=sTable;
}
public void setOrderBy(String sOrder){
m_sOrder=sOrder;
}
public void setCurrentNo(int iCurrentNo){
m_iCurrentNo=iCurrentNo m_iTotal)
m_iCurrentNo = m_iTotal;
m_iEnd = m_iSize * m_iCurrentNo;
m_iBegin = m_iEnd - m_iSize + 1;
if(m_iBegin m_iCount)
m_iEnd = m_iCount;
//print("SELECT "+m_sFields+" FROM "+m_sTable+
// m_sFilter+m_sOrder+" LIMIT "+String.valueOf(m_iBegin - 1)+","+String.valueOf(m_iSize));
try{
return stmt.executeQuery("SELECT "+m_sFields+" FROM "+m_sTable+
m_sFilter+m_sOrder+" LIMIT "+String.valueOf(m_iBegin - 1)+","+String.valueOf(m_iSize));
}catch(SQLException e){
close();
throw new ServletException("MyPage: Get ResultSet Error!");
}
}
public int getCurrentNo(){
return m_iCurrentNo;
}
public int getCount(){
return m_iCount;
}
public int getTotal(){
return m_iTotal;
}
public int getBegin(){
return m_iBegin;
}
public int getEnd(){
return m_iEnd;
}
public boolean hasPrevious(){
return (m_iCurrentNo > 1 && m_iTotal != 1);
}
public boolean hasNext(){
return (m_iCurrentNo != m_iTotal && m_iTotal != 1);
}
public boolean hasFirst(){
return hasPrevious();
}
public boolean hasLast(){
return hasNext();
}
}
jsp中使用方法:
page.jsp:
test_css
客户编号
公司名称
联系人
所在部门
公司地址
城 市
0)
{
for (int i = 0 ;i
package KWT;
import javax.servlet.*;
//import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class MyPage{
/*
public JspWriter out=null;
private void print(String str) throws ServletException{
try{
out.print(str);
}catch(java.io.IOException e){
throw new ServletException(e);
}
}
*/
private int m_iSize=0;
private String m_sFields=null;
private String m_sFilter=null;
private String m_sTable=null;
private String m_sOrder=null;
private int m_iCurrentNo=0;
private Connection m_oConn=null;
private int m_iCount=0;
private int m_iTotal=0;
private int m_iBegin=0;
private int m_iEnd=0;
public void setSize(int iSize){
m_iSize=iSize;
}
public void setFields(String sFields){
m_sFields=sFields;
}
public void setWhere(String sFilter){
m_sFilter=sFilter;
}
public void setTable(String sTable){
m_sTable=sTable;
}
public void setOrderBy(String sOrder){
m_sOrder=sOrder;
}
public void setCurrentNo(int iCurrentNo){
m_iCurrentNo=iCurrentNo m_iTotal)
m_iCurrentNo = m_iTotal;
m_iEnd = m_iSize * m_iCurrentNo;
m_iBegin = m_iEnd - m_iSize + 1;
if(m_iBegin m_iCount)
m_iEnd = m_iCount;
//print("SELECT "+m_sFields+" FROM "+m_sTable+
// m_sFilter+m_sOrder+" LIMIT "+String.valueOf(m_iBegin - 1)+","+String.valueOf(m_iSize));
try{
return stmt.executeQuery("SELECT "+m_sFields+" FROM "+m_sTable+
m_sFilter+m_sOrder+" LIMIT "+String.valueOf(m_iBegin - 1)+","+String.valueOf(m_iSize));
}catch(SQLException e){
close();
throw new ServletException("MyPage: Get ResultSet Error!");
}
}
public int getCurrentNo(){
return m_iCurrentNo;
}
public int getCount(){
return m_iCount;
}
public int getTotal(){
return m_iTotal;
}
public int getBegin(){
return m_iBegin;
}
public int getEnd(){
return m_iEnd;
}
public boolean hasPrevious(){
return (m_iCurrentNo > 1 && m_iTotal != 1);
}
public boolean hasNext(){
return (m_iCurrentNo != m_iTotal && m_iTotal != 1);
}
public boolean hasFirst(){
return hasPrevious();
}
public boolean hasLast(){
return hasNext();
}
}
jsp中使用方法:
page.jsp:
test_css
客户编号
公司名称
联系人
所在部门
公司地址
城 市
0)
{
for (int i = 0 ;i
|
贴上我的程序。可是没有放到arraylist里。
page Find_Client_Info,'*',,12,"truename='' or truename='共享'"
客户名称
联系人
电话
客户状态
拥有人
页
page Find_Client_Info,'*',,12,"truename='' or truename='共享'"
客户名称
联系人
电话
客户状态
拥有人
页