![]() |
#2
经哥2014-01-08 16:19
这是我想实现的后的代码页面
![]() package dbbean; <%@ page language = "java" contentsType ="text/html; charset = GB2312" pageEncoding = "GB2312"%> <%@ page import = "java.sql.*"%> !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=GB2312"> <title>学生管理面板</title> <style type="text/css"> <!-- .STYLE1 { font-size: 36px; font-weight: bold; } --> </style> /head> <body background="image\3.jpg"> <form name="form1" method="get" action="bookDel.jsp"> <table width="600" border="1" align="center" bgColor="#ffffff"> <caption> <span class="STYLE1"><br><br><br>学生管理面板 </span> </caption> <tr> <td width="98" bgColor="#808000">全选 <input type="checkbox" name="checkbox" value="checkbox"></td> <td width="98" bgColor="#808000">学号</td> <td width="118" bgColor="#808000">姓名</td> <td width="108" bgColor="#808000">性别</td> <td width="78" bgColor="#808000">年龄</td> <td width="60" bgColor="#808000">操作</td> </tr> <% String strPage=request.getParameter("page"); int curPage=1;//当前显示的页数 if(strPage!=null){ curPage=Integer.parseInt(strPage); } Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bk","root","123"); PreparedStatement ps = con.prepareStatement("select * from t_book"); ResultSet rs = ps.executeQuery(); //每页显示3条,得到总页数 rs.last();//游标指针滚动到最后一行 int row = rs.getRow();//得到当前记录行数 int pages = row%3!=0?row/3+1:row/3;//计算出总页数 rs.beforeFirst();//还原到首行之前 //定位器 int position = (curPage-1)*3; if(position!=0){ rs.absolute(position); } int count=0;//计数器 while(rs.next()&&count<3){ count++; %> <tr> <td><input type="checkbox" name="ids" value="<%=rs.getInt("id") %>"></td> <td><%=rs.getInt("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("age") %></td> <td><%=rs.getInt("sex") %></td> <td><a href="bookEdit.jsp?id=<%=rs.getInt("id")%>">编辑</a></td> </tr> <% } con.close(); %> <tr> <td colspan="6" align="center" bgColor="#ff8000"><input type="submit" name="Submit" value="删除图书"> <input name="add" type="button" id="add" value="添加图书" onClick="location='bookAdd.jsp'"> <a href="bookList.jsp?page=1">首页</a> <a href="bookList.jsp?page=<%=curPage-1 %>">上一页</a> <a href="bookList.jsp?page=<%=curPage+1 %>">下一页</a> <a href="bookList.jsp?page=<%=pages %>">尾页</a> </td> </tr> </table> </form> </body> </html> |

<%@ page language="java" contentType="text/html; charset=GB2312"
pageEncoding="GB2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录学生信息管理系统 </title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 36px;
font-weight: bold;
}
-->
</style>
</head>
<body bgcolor="" background="image\3.jpg">
<form name="form1" method="post" action="studentsList.jsp">
<table width="420" height="182" border="0" align="center" bgColor="#c0c0c0">
<caption>
<span class="STYLE1"><br><br><br>登陆学生信息管理系统<br></span>
</caption>
<tr>
<td width="166" bgColor="#808000"> 用户名:</td>
<td width="318" bgColor="#808000"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td bgColor="#808000"> 密码:</td>
<td bgColor="#808000"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center" bgColor="#408080"><input type="submit" name="Submit" value="登录">
<input type="reset" name="Submit2" value="取消"></td>
</tr>
</table>
</form>
</body>
</html>
pageEncoding="GB2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录学生信息管理系统 </title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 36px;
font-weight: bold;
}
-->
</style>
</head>
<body bgcolor="" background="image\3.jpg">
<form name="form1" method="post" action="studentsList.jsp">
<table width="420" height="182" border="0" align="center" bgColor="#c0c0c0">
<caption>
<span class="STYLE1"><br><br><br>登陆学生信息管理系统<br></span>
</caption>
<tr>
<td width="166" bgColor="#808000"> 用户名:</td>
<td width="318" bgColor="#808000"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td bgColor="#808000"> 密码:</td>
<td bgColor="#808000"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center" bgColor="#408080"><input type="submit" name="Submit" value="登录">
<input type="reset" name="Submit2" value="取消"></td>
</tr>
</table>
</form>
</body>
</html>