std.jsp~76~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:4k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- <%@ page contentType="text/html; charset=GBK" %>
- <%@ page import="java.sql.*" %>
- <%@ page language="java" %>
- <%@ page import="java.util.*" %>
- <%@ page import="proj112.*" %>
- <jsp:useBean id="a" scope="page" class="proj112.dbconn"/>
- <html>
- <head>
- <style type="TEXT/CSS">
- A:LINK{COLOR:blue;FONT-SIZE:11PT;TEXT-DECORATION:NONE}
- A:VISITED{COLOR:blue;FONT-SIZE:11PT;TEXT-DECORATION:NONE}
- A:HOVER{COLOR:red;FONT-SIZE:11PT;TEXT-DECORATION:UNDERLINE}</STYLE>
- <title>
- kecheng1
- </title>
- </head>
- <body bgcolor="#ffffff"><br>
- <center> 在这个页面你可以进行<font size="3" color="red">添加、修改、删除</font>操作!!!
- <script language="JavaScript">
- <!--
- function del(id)
- {
- if (confirm("您确信要删除吗?") )
- top.location="delete.jsp?id='"+name+"'"
- }
- </script>
- <%
- int PageSize = 6;
- int Page = 1;
- int totalPage = 1;
- int totalrecord = 0;
- String id = "";
- String sql = null;
- ResultSet rs = null;
- //算出总行数
- sql = "SELECT count(*) as recordcount FROM student";
- rs = a.executeQuery(sql);
- if (rs.next()) totalrecord = rs.getInt("recordcount");
- //输出记录
- sql = "SELECT * FROM student";
- rs = a.executeQuery(sql);
- %>
- <br><br>
- <p align="center">
- <table width="100%" cellspacing="0" cellpadding="4" rules="all" bordercolor="#CC9966" border="1" id="dg_rxkb" style="background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:100%;border-collapse:collapse;">
- <tr align=middle>
- <td colspan="6" ><font color="red">所有学生信息</font></td>
- <td align="center"><a href="addForm.jsp"><font color="blue">添加一条纪录</a></div></td>
- </tr>
- <tr>
- <td align="center"><font color="#6633CC">姓名</font></td>
- <td align="center"><font color="#6633CC">学号</font></td>
- <td align="center"><font color="#6633CC">性别</font></td>
- <td align="center"><font color="#6633CC">专业</font></td>
- <td align="center"><font color="#6633CC">民族</font></td>
- <td align="center"><font color="#6633CC">政治面貌</font></td>
- <td align="center"><font color="#6633CC">管理</font></td>
- </tr>
- <%
- 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=sdfsdfsdf所造成的异常
- Page = 1;
- }
- if(Page < 1) Page = 1;
- if(Page > totalPage) Page = totalPage;
- rs.absolute((Page-1) * PageSize + 1); %>
- <%
- for(int iPage=1; iPage<=PageSize; iPage++) {
- String name=rs.getString("stu_name"); %>
- <div align="right"></div> </td>
- </tr>
- <tr>
- <td align="center"><%=rs.getString("stu_name")%></td>
- <td align="center"><%=rs.getString("stu_id")%></td>
- <td align="center"><%=rs.getString("sex")%></td>
- <td align="center"><%=rs.getString("dept")%></td>
- <td align="center"><%=rs.getString("mz")%></td>
- <td align="center"><%=rs.getString("zzmm")%></td>
- <td align="center" width=20%><a href="change.jsp?id=<%=name%>">修改</a> | <a href="delete.jsp?id=<%=name%>">删除</a></td>
- </tr>
- <% if(!rs.next()) break;
- }
- %>
- </table>
- <FORM Action="std.jsp" Method="GET">
- <%
- if(Page != 1) {
- out.print(" <A HREF=std.jsp?Page=1> 第一页 </A>");
- out.print(" <A HREF=std.jsp?Page=" + (Page-1) + "> 上一页 </A>");
- }
- if(Page != totalPage) {
- out.print(" <A HREF=std.jsp?Page=" + (Page+1) + "> 下一页 </A>");
- out.print(" <A HREF=std.jsp?Page=" + totalPage + "> 最后一页 </A>");
- }
- %>
- 输入页数:<input TYPE="TEXT" Name="Page" SIZE="3">
- 页数:<font COLOR="Red"><%=Page%>/<%=totalPage%></font>
- <INPUT TYPE="submit" value="提交">
- </FORM>
- </body>
- </html>