kecheng1.jsp~19~
资源名称: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:black;FONT-SIZE:9PT;TEXT-DECORATION:NONE}
- A:VISITED{COLOR:blue;FONT-SIZE:9PT;TEXT-DECORATION:NONE}
- A:HOVER{COLOR:GREEN;FONT-SIZE:10PT;TEXT-DECORATION:UNDERLINE}</STYLE>
- <title>
- kecheng1
- </title>
- </head>
- <body bgcolor="#ffffff"><br>
- 姓名: <font color="#0033FF"><%=session.getAttribute("stu_name") %> </font> 学号: <font color="#0033FF"><%=session.getAttribute("id") %></font><br>
- <hr><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);
- %>
- <form action="kecheng2.jsp" method="POST" name="form3">
- <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="7" bgcolor="#EcEcff"><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++) { %>
- <div align="right"></div> </td>
- </tr>
- <tr>
- <td align="center"><a href="kecheng2.jsp?id2=<%=rs.getString(1)%>" >添加</a></td>
- <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>
- </tr>
- <% if(!rs.next()) break;
- }
- %>
- </table>
- </form>
- <FORM Action="kecheng1.jsp" Method="GET">
- <%
- if(Page != 1) {
- out.print(" <A HREF=kecheng1.jsp?Page=1> 第一页 </A>");
- out.print(" <A HREF=kecheng1.jsp?Page=" + (Page-1) + "> 上一页 </A>");
- }
- if(Page != totalPage) {
- out.print(" <A HREF=kecheng1.jsp?Page=" + (Page+1) + "> 下一页 </A>");
- out.print(" <A HREF=kecheng1.jsp?Page=" + totalPage + "> 最后一页 </A>");
- }
- %>
- 输入页数:<input TYPE="TEXT" Name="Page" SIZE="3">
- 页数:<font COLOR="Red"><%=Page%>/<%=totalPage%></font>
- <INPUT TYPE="submit" value="提交">
- </FORM>
- </body>
- </html>