?? addtest.jsp
字號(hào):
<%@ page language="java" import="java.util.*,com.zte.database.Database,java.sql.*" pageEncoding="gbk"%>
<%
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 'addtest.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">
<!--
.STYLE22 { color: #0000FF;
font-size: 18px;
font-weight: bold;
}
.STYLE24 {font-size: 16px}
.STYLE25 {color: #0000FF}
.STYLE28 {font-size: 14px}
-->
</style>
<script language="javascript">
function f1(currentpage,totalpage)
{
if(currentpage.value>totalpage)
{
alert('已經(jīng)是最后一頁(yè)');
document.getElementById('page').focus();
return false;
}
}
</script>
<%
String flag=request.getParameter("flag");
if(flag!=null)
{
if(flag.equals("success"))
{
%>
<script>
alert("刪除成功!");
</script>
<%
}
}
%>
<%
int pagesize; //一頁(yè)顯示的記錄數(shù)
int pagecount; //總頁(yè)數(shù)
int rowcount; //記錄總數(shù)
int intpage; //待顯示頁(yè)碼
int i;
String strpage;
pagesize=5; //設(shè)置一頁(yè)顯示的記錄數(shù)
strpage=request.getParameter("page"); //取得待顯示頁(yè)碼
if(strpage==null) //表明在QueryString中沒有page這一個(gè)參數(shù),此時(shí)顯示第一頁(yè)數(shù)據(jù)
{
intpage=1;
}else
{
intpage=Integer.parseInt(strpage);
if(intpage<0)
{
intpage=1;
}
}
%>
</head>
<body>
<table width="620" border="0" align="center">
<tr>
<td colspan="2" align="center">
<input type="image" name="imageField" src="image/zte.jpg" />
</td>
</tr>
<tr>
<td width="134" rowspan="2" valign="top">
<span class="STYLE25"><a href="">試題數(shù)據(jù)管理</a></span><span class="STYLE24"><br />
<span class="STYLE28">
<a href="admin/addtest.jsp">預(yù)覽全部試題</a><br>
<a href="admin/addtesttitle.jsp">添加考試類型</a><br>
<a href="admin/selecttestpaper.jsp">添加試題</a></span><br>
<span class="STYLE25"><a href="admin/adduser.jsp">考生數(shù)據(jù)管理</a></span></span></td>
<td width="490" height="280" valign="top" align="center"><div>
<table width="490" border="0">
<tr><td colspan="4" align="center"><span class=" STYLE22">全部試題信息</span></td></tr>
<tr>
<td width="160" align="left">題 目</td>
<td width="70" align="left">科 目</td>
<td width="70" align="left">分 數(shù)</td>
<td width="65" align="left">類 型</td>
<td width="65" align="left">刪 除</td>
</tr>
<%
String sql="select * from exam_question";
Database db = new Database();
ResultSet rs=db.query(sql);
rs.last(); //光標(biāo)在最后一行
rowcount=rs.getRow(); //獲得當(dāng)前行號(hào)
pagecount=(rowcount+pagesize-1)/pagesize; //記算總頁(yè)數(shù)
if(intpage>pagecount) //調(diào)整待顯示的頁(yè)碼
{
intpage=pagecount;
}
if(pagecount>0)
{
rs.absolute((intpage-1)*pagesize+1); //將記錄指針定位到待顯示頁(yè)的第一條記錄上
i=0; //顯示數(shù)據(jù)
while(i<pagesize&&!rs.isAfterLast())
{
String line="<tr><td>";
line+=rs.getString("qutitle")+"</td><td> ";
line+=rs.getString("testtitle")+"</td><td> ";
line+=rs.getString("quscore")+"</td><td>";
line+=rs.getString("qutype")+"</td><td> ";
line+="<a href='deletetestservlet?id=";
line+=rs.getString("qu_id")+"'>刪除</a></td></tr>";
out.println(line);
rs.next();
i++;
}
}
%>
</table>
</div></td>
</tr>
<tr>
<td height="30" align="center">
<div>
<table width="490" border="0">
<tr>
<td>
<form method="POST" action="admin/addtest.jsp" onSubmit="return f1(page,<%=pagecount%>)">
<div align="center">第<%=intpage%>頁(yè) 共<%=pagecount%>頁(yè)
<%
if(intpage<pagecount)
{
%>
<a href="admin/addtest.jsp?page=<%=intpage+1%>" onclick="f1(<%=intpage%>,<%=pagecount%>)">下一頁(yè)
</a>
<%
}
%>
<%
if(intpage>1)
{
%>
<a href="admin/addtest.jsp?page=<%=intpage-1%>">上一頁(yè) </a>
<%
}
%>
跳轉(zhuǎn)到第<input type="text" name="page" size="6"> 頁(yè)
<span><input class=buttonface type="submit" value="GO" name="cndok"></span>
</div>
</form>
</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="2">
<input type="image" name="imageField2" src="image/ztebottom.jpg" />
</td>
</tr>
</table>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -