?? selectuser.jsp
字號:
<%@ page language="java" import="java.util.*,java.sql.*,com.zte.database.*,com.zte.beans.*" pageEncoding="gbk"%>
<%@page import="com.zte.beans.ExamSystem;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'selectuser.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style>
a{text-decoration:none;}
</style>
<style type="text/css">
<!--
.STYLE18 {font-size: 14px}
.STYLE20 {
color: #0000FF;
font-size: 16px;
font-family: "楷體_GB2312";
}
.STYLE21 {
font-size: 16px;
font-family: "楷體_GB2312";
}
.STYLE22 {color: #0000FF}
.STYLE23 {font-family: "楷體_GB2312"}
-->
</style>
<script language="javascript">
function f1(currentpage,totalpage)
{
if(currentpage.value>totalpage)
{
alert('已經(jīng)是最后一頁');
document.getElementById('page').focus();
return false;
}
}
</script>
<%
String url;
Connection con;
Statement sta;
ResultSet rs;
String sql;
int pagesize; //一頁顯示的記錄數(shù)
int pagecount; //總頁數(shù)
int rowcount; //記錄總數(shù)
int intpage; //待顯示頁碼
int i;
String strpage;
pagesize=4; //設(shè)置一頁顯示的記錄數(shù)
strpage=request.getParameter("page"); //取得待顯示頁碼
if(strpage==null) //表明在QueryString中沒有page這一個參數(shù),此時顯示第一頁數(shù)據(jù)
{
intpage=1;
}else
{
intpage=Integer.parseInt(strpage); //將字符串轉(zhuǎn)換成整型
if(intpage<0)
{
intpage=1;
}
}
url="jdbc:oracle:thin:@localhost:1521:lihao";
con=DriverManager.getConnection(url,"lihao","lihao");
sta=con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
sql="select * from exam_student";
rs=sta.executeQuery(sql);
rs.last(); //光標(biāo)在最后一行
rowcount =rs.getRow(); //獲得當(dāng)前行號
pagecount=(rowcount+pagesize-1)/pagesize; //記算總頁數(shù)
if(intpage>pagecount) //調(diào)整待顯示的頁碼
{
intpage=pagecount;
}
%>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="696" border="0" align="center">
<tr>
<td colspan="2" align="center"><input type="image" name="imageField" src="file:///C|/Documents and Settings/lenvoo/桌面/zte.jpg" /></td>
</tr>
<tr>
<td width="103" rowspan="2" valign="top">
<br>
<span class="STYLE22"><a href="admin/loginsuccess.jsp">試題數(shù)據(jù)管理</a></span>
<span class="STYLE24">
<span class="STYLE25"><a href="admin/adduser.jsp">考生數(shù)據(jù)管理</a></span></span>
<span class="STYLE18"><span class="STYLE19">
<a href="admin/selectuser.jsp">瀏覽考生</a>
<a href="admin/adduser.jsp">添加考生</a></span></span></td>
<td width="577" height="280" valign="top">
<div>
<table width="574" border="0">
<tr><td colspan="6" align="center">全部考生信息</td><br></tr>
<tr>
<td width="117" align="center">身份證</td>
<td width="84" align="center">姓名</td>
<td width="65" align="center">班級</td>
<td width="90" align="center">學(xué)號</td>
<td width="116" align="center">Email</td>
<td width="62" align="center">刪除</td>
</tr>
<%
if(pagecount>0)
{
rs.absolute((intpage-1)*pagesize+1); //將記錄指針定位到待顯示頁的第一條記錄上
i=0; //顯示數(shù)據(jù)
//String sql="select * from exam_student";
//Database db = new Database();
//ResultSet rs=db.query(sql);
while(i<pagesize&&!rs.isAfterLast())
{
String line="<tr><td>";
line+=rs.getString("humanId")+"</td><td> ";
line+=rs.getString("stuName")+"</td><td> ";
line+=rs.getString("className")+"</td><td>";
line+=rs.getString("stuNumber")+"</td><td> ";
line+=rs.getString("stuMail")+"</td><td> ";
line+="<a href='deleteuser?humanid="+rs.getString("humanId")+"'>刪除</a></td></tr>";
out.println(line);
rs.next();
i++;
}
}
%>
</table>
</div></td>
</tr>
<tr>
<td height="33" align="center">
<div>
<table width="500" border="0">
<tr>
<td align="center">
<form method="POST" action="page.jsp" onSubmit="return f1(page,<%=pagecount%>)">
<div align="center">
第<%=intpage%>頁 共<%=pagecount%>頁
<%
if(intpage<pagecount)
{
%>
<a href="main.jsp?page=<%=intpage+1%>" onclick="f1(<%=intpage%>,<%=pagecount%>)">下一頁
</a>
<%
}
%>
<%
if(intpage>1)
{
%>
<a href="main.jsp?page=<%=intpage-1%>">上一頁 </a>
<%
}
%>
跳轉(zhuǎn)到第<input type="text" name="page" size="6"> 頁
<span><input class=buttonface type="submit" value="GO" name="cndok"></span>
</div>
</form> </td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="image" name="imageField2" src="file:///C|/Documents and Settings/lenvoo/桌面/ztebottom.jpg" /></td>
</tr>
</table>
</form>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -