“jsp实现文本分页显示”的代码 急求!!!

2025-01-18 16:02:00
推荐回答(1个)
回答1:

这里有分页显示的代码。我自己做的,可能不是很全。
<%
String query_type=request.getParameter("select");//获取查询类别
if(query_type!=null)
query_type=(new String(query_type.getBytes("ISO-8859-1"))).trim();
System.out.println(query_type);
String query_content=request.getParameter("query");//获取查询关键字,查询为模糊查询

if(query_content==null)
query_content="";
System.out.println("query");
query_content=(new String(query_content.getBytes("ISO-8859-1"))).trim();
if(!query_content.equals("")&&query_type!=null){
if(query_type.equals("编号")){
odbcQuery="Select * from Member where number ='"+query_content+"'";

}
else
odbcQuery="Select * from Member where name like'"+query_content+"%'";

}
else
odbcQuery="Select * from Member";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}
catch(ClassNotFoundException e){e.printStackTrace();}

try{
System.out.println(odbcQuery);
Connection con=DriverManager.getConnection("jdbc:odbc:War3","sa","123456");
Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=sql.executeQuery(odbcQuery);
System.out.println(rs.next());
rs.last();
int lastRow = rs.getRow();//获取最后一行的方法
pageCount = (lastRow%pageSize == 0 )?(lastRow/pageSize):(lastRow/pageSize+1);
int showPage =1 ;//当前页码的值

%