📄 index.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="data.LoginData"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/html">
<!--
.STYLE1 {font-size: 9px}
-->
</style>
<style type="text/css">
<!--
.STYLE9 {font-size: 24px; font-weight: bold; color: #3399FF; }
.STYLE10 {font-size: 24px; font-weight: bold; color: #000000; }
.STYLE11 {
font-size: 24px;
color: #3366CC;
font-family: "宋体";
}
-->
</style>
</head>
<body>
<jsp:useBean id="show" class="Bean.MachSearch" scope="page">
</jsp:useBean>
<jsp:useBean id="connDbBean" scope="page" class="db.dbConn"/>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String strSql="";
int PageSize=15;
int Page=1;
int totalPage=1;
int totalrecord=0;
int totalrecord1=0;
%>
<table width="975" border="0" cellpadding="0" cellspacing="0" bordercolor="#333399">
<!--DWLayoutTable-->
<tr>
<td height="76" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="171" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="171" height="76" valign="middle"><img src="image/tushu2.bmp" /></td>
</tr>
</table> </td>
<td width="75" height="28"> </td>
<td width="100"> </td>
<td width="18"> </td>
<td width="101"> </td>
<td width="26"> </td>
<td width="100"> </td>
<td width="30"> </td>
<td width="100"> </td>
<td width="49"> </td>
<td width="100"> </td>
<td width="105"> </td>
</tr>
<tr>
<td height="48"> </td>
<td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="102" height="48" align="center" valign="bottom" bgcolor="#E4E4E4"><a href="Search.jsp" class=STYLE10 STYLE11 >图书检索</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#E4E4E4"><a href="Mylibary.jsp" class="STYLE10"><strong>我的图书</strong></a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#E4E4E4"><a href="index.jsp" class="STYLE10">新书通报</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#E4E4E4" class="STYLE9"><a href="test.jsp" class="STYLE10">信息发布</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="975" height="30" bgcolor="#3366CC"> </td>
</tr>
</table> </td>
</tr>
<tr>
<td width="174" height="14"> </td>
<td width="698"> </td>
<td width="103"> </td>
</tr>
<tr>
<td height="262"> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="200" height="33"> </td>
<td width="271" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="271" height="33" align="center" valign="middle"><span class="STYLE11">新书架</span></td>
</tr>
</table> </td>
<td width="227"> </td>
</tr>
<tr>
<td height="229" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="698" height="229" valign="top">
<p>
<%
try{
LoginData loginData = new LoginData();
conn = loginData.getConn();
stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//算出总行数
strSql = "SELECT count(*) as recordcount FROM grade";
rs = stmt.executeQuery(strSql);
if (rs.next()) totalrecord = rs.getInt("recordcount");
strSql= "SELECT * FROM grade";
rs = stmt.executeQuery(strSql);
if(totalrecord%PageSize==0)totalPage=totalrecord/PageSize;
else totalPage=(int)Math.floor(totalrecord/PageSize)+1;
if(totalPage==0)totalPage=1;
if(request.getParameter("Page")==null||request.getParameter("Page").equals(""))
Page=1;
else{
try{
Page=Integer.parseInt(request.getParameter("Page"));
}catch(java.lang.NumberFormatException e){
Page=1;
}
}
if(Page<1)Page=1;
if(Page>totalPage)Page=totalPage;
rs.absolute((Page-1)*PageSize+1);
out.print("<table border='1' width='700' border='300' cellpadding='0' cellspacing='0' bordercolor='#3366CC'>");
out.print("<tr bgcolor='#6699CC'><td><font color=''><b>"+"学号"+"</b></font></td>");
out.print("<td><font color=''><b>"+"性别"+"</b></font></td>");
out.print("<td><font color='r'><b>"+"姓名"+"</b></font></td>");
out.print("<td><font color=''><b>"+"语文"+"</b></font></td>");
out.print("<td><font color=''><b>"+"数学"+"</b></font></td>");
out.print("<td><font color=''><b>"+"英语"+"</b></font></td>");
out.print("<td><font color=''><b>"+"查看"+"</b></font></td></tr>");
for(int iPage=1;iPage<=PageSize;iPage++) {
out.print("<tr><td>"+rs.getInt("学号")+"</td>");
out.print("<td>"+rs.getString("性别")+"</td>");
out.print("<td>"+rs.getString("姓名")+"</td>");
out.print("<td>"+rs.getInt("语文")+"</td>");
out.print("<td>"+rs.getInt("数学")+"</td>");
out.print("<td>"+rs.getInt("英语")+"</td>");
out.print("<td>"+"详细信息"+"</td></tr>");
if(!rs.next()) break;
}
out.print("</table>");
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally{
stmt.close();
conn.close();
}
%>
</p>
<p>
<form action="index.jsp" method="get">
<p><span class="STYLE2"><strong>
<%
if(Page!=1){
out.print(" <a href=index.jsp?Page=1>第一页</a>");
out.print(" <a href=index.jsp?Page="+(Page-1)+"></a> ");
}
if(Page!=totalPage){
out.print(" <a href=index.jsp?Page="+(Page+1)+"></a>");
out.print(" <a hreg=index.jsp?Page="+totalPage+"></a>");
}
%>
<br>
</strong></span><strong>输入页书</strong><span class="STYLE2"><strong>:
<input type="text" name="Page" size="5">
</strong></span><strong>页数</strong><span class="STYLE2"><strong>:<font color="red"><%=Page%>/<%=totalPage%></font>
</strong></span></p>
</form>
</p></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td> </td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -