list_kecheng.jsp~11~
资源名称: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:12PT;TEXT-DECORATION:NONE}
- A:VISITED{COLOR:blue;FONT-SIZE:12PT;TEXT-DECORATION:NONE}
- A:HOVER{COLOR:red;FONT-SIZE:12PT;TEXT-DECORATION:UNDERLINE}</STYLE>
- <title>
- kecheng1
- </title>
- </head>
- <body bgcolor="#ffffff"><br>
- <%
- 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 kecheng";
- rs = a.executeQuery(sql);
- if (rs.next()) totalrecord = rs.getInt("recordcount");
- //输出记录
- sql = "SELECT * FROM kecheng";
- rs = a.executeQuery(sql);
- %>
- <p align="center">
- <table 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="7" bgcolor="#9dcaf4"><font color="red">所有课程信息</font></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("kch");%>
- <div align="right"></div> </td>
- </tr>
- <tr>
- <td align="center"><%=rs.getString(1)%></td>
- <td align="center"><%=rs.getString(2)%></td>
- <td align="center"><%=rs.getString(3)%></td>
- <td align="center"><%=rs.getString(4)%></td>
- <td align="center"><%=rs.getString(5)%></td>
- <td align="center"><%=rs.getString(6)%></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="list_kecheng.jsp" Method="GET">
- <%
- if(Page != 1) {
- out.print(" <A HREF=list_kecheng.jsp?Page=1> 第一页 </A>");
- out.print(" <A HREF=list_kecheng.jsp?Page=" + (Page-1) + "> 上一页 </A>");
- }
- if(Page != totalPage) {
- out.print(" <A HREF=list_kecheng.jsp?Page=" + (Page+1) + "> 下一页 </A>");
- out.print(" <A HREF=list_kecheng.jsp?Page=" + totalPage + "> 最后一页 </A>");
- }
- %>
- 输入页数:<input TYPE="TEXT" Name="Page" SIZE="3">
- 页数:<font COLOR="Red"><%=Page%>/<%=totalPage%></font>
- <INPUT TYPE="submit" value="提交">
- </FORM>
- </body>
- </html>