⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list1.jsp

📁 说什么啊 自己去看 还至少20个字 真服了 着拉
💻 JSP
字号:
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*,java.util.*;" errorPage=""%>
<html>
<head>
<title>学籍管理系统</title>
</head>
<%!	String url,sql; %>
<%!	Connection conn;//定义数据库连接对象 %>
<%!	ResultSet rs,rscount;//定义结果集对象,及结果集的记录行数 %>
<%!	Statement stmt;//定义SQL语句对象 %>
<%! int i;%>
<%! int pageSize=10;//定义每页显示的记录行数%>
<%! int rowCount=0;//定义总的记录行数%>
<%! int pageCurrent;//当前的页数%>
<%! int pageCount;//总的页数%>

<body bgcolor="#ffffff">
<div align="center"><font color="#000000" size="5">学籍管理系统 </font> </div>
<table width="75%" border="1" cellspacing="1" cellpadding="1" align="center">
  <tr>
    <td width=16% align=center>学号</td>
	<td width=16% align=center>姓名</td>
	<td width=8% align=center>性别</td>
	<td width=8% align=center>年龄</td>
	<td width=16% align=center>籍贯</td>
	<td width=12% align=center>院系</td>
	<td width=12% align=center>更改</td>
	<td width=12% align=center>删除</td>
  </tr>
  <%
	try{
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
      url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=university";
	  conn=DriverManager.getConnection(url,"admin","123456");//建立与数据库的连接
	  stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
	  sql="select * from student"; 
	  rs=stmt.executeQuery(sql);//查询数据库
	  String sqlcount="select count(*) from student";
	  rscount=stmt.executeQuery(sqlcount);
	  rowCount=rscount.getInt(0);//获取student表中总的记录行数
	  String strPage=request.getParameter("page");//获取参数page
	  if(strPage==null){//如果page为null则表示为第一页,设置pageCurrent的值为1
		pageCurrent=1;
	  }
	  else{//如果pageCurrent的值小于1,同样设置pageCurrent的值为1
		pageCurrent=Integer.paseInt(strPage);
		if(pageCurrent<1)
		  pageCurrent=1;
	  }
	  for(i=1;i<(pageCurrent-1)*pageSize;i++)
		rs.next();
	  for(i=1;i<pageSize;i++){//将数据集中的数据指针指向第pageCurrent页的数据,该页显示的数据记录数为pageSize
		if(rs.next()){
  %>
  <tr>
    <td width=16% align=center><%=rs.getObject(1)%></td>
	<td width=16% align=center><%=rs.getObject(2)%></td>
	<td width=8% align=center><%=rs.getObject(3)%></td>
	<td width=8% align=center><%=rs.getObject(4)%></td>
	<td width=16% align=center><%=rs.getObject(5)%></td>
	<td width=12% align=center><%=rs.getObject(6)%></td>
	<td width=12% align=center><a href="change.jsp?xuehao=<%=rs.getObject(1)%>">修改</a></td>
	<td width=12% align=center><a href="del.jsp?xuehao=<%=rs.getObject(1)%>">删除</a></td>
  </tr>
  <%
	    }
	  }
	  rs.close();
	  stmt.close();
	  conn.close();
	  pageCount=(int)(rowCount/pageSize);//计算总的页数,如果总页数>1则显示1,2,...,n(n表示总的页数)
	  if(pageCount*pageSize<rowCount)
		pageCount++;
	  if(pageCount>1){
	    for(i=1;i<pageCount;i++)
		  out.print(\"<a href=list.jsp?page=\"+i+\">\"+i+\" </a>\");  
	  }
	}catch(Exception e){
	  out.println(e);
	}
  %>
</table>
<div align="center"><a href="insert.jsp">添加新记录 </a> </div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -