实在是看不到那出错了
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
My JSP 'search_result.jsp' starting page
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String strConn="jdbc:sqlserver://PC201311011725\MSSQLSERVER:1433;DatabaseName=Xk";
String strUser="sa";
String strPWD="feng123";
conn=DriverManager.getConnection(strConn,strUser,strPWD);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
String str1=request.getParameter("txt1");
String strSql="";
if(str1==null || str1==""){
strSql="select * from studnet";
}else{
strSql="select * from student where stuname like '"+str1.trim()+"%'";
}
rs=stmt.executeQuery(strSql);
}catch(Exception e){
}
%>
<%
String str=(String)request.getParameter("page");
if(str==null){
str="0";
}
int pagesize=5;//每页地 个数
rs.last();
int recordCount=rs.getRow();//总行数
int maxPage=0;
maxPage=(recordCount%pagesize==0)?(recordCount/pagesize):(recordCount/pagesize+1);//可以分成多少个页面
int currentPage=Integer.parseInt(str);//当前页面
if(currentPage currentPage=1;
}
else{
if(currentPage>maxPage){
currentPage=maxPage;
}
}
rs.absolute((currentPage-1)*pagesize+1);//定位到每个当前页面的第一个元素
for(int i=1;i<=pagesize;i++){
%>
<%
try{
if(!rs.next()){break;}
}catch(Exception e){
}
}
%>
stuno | classno | stuname | Pwd |
---|---|---|---|
<%=rs.getString(1) %> | <%=rs.getString(2) %> | <%=rs.getString(3) %> | <%=rs.getString(4) %> |
跳转到第一页
">下一页