点击下一页之后没有任何反应。。。而且跳转到某一页功能也不能实现
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%!
public static final String URL = "emp_list.jsp";
public static final String DBDRIVER = "com.mysql.jdbc.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static final String DBUSER = "root";
public static final String DBPASS = "root";
%>
<%
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
%>
<%
int currentPage = 1; //当前所在页,默认为1
int lineSize = 3; //每次显示的记录数
int allRecorders = 0; //表示全部的记录
int pageSize = 1; //表示全部的页数(尾页)
int [] lsData = {1,3,5,7,9};
%>
<%
try {
String cPage = request.getParameter("cp");
if (cPage==null){
cPage="1";
}
String lSize = request.getParameter("ls");
if (lSize==null){
lSize = "3";
}
currentPage = Integer.parseInt(cPage);
lineSize = Integer.parseInt(lSize);
}catch(Exception e){
System.out.println("错误1");
}
%>
<%
try {
Class.forName(DBDRIVER);
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS);
String sql = "select COUNT(empno) from emp";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()){
allRecorders = rs.getInt(1);
}
//System.out.println(allRecorders);
pageSize = (allRecorders + lineSize -1) / lineSize;
//System.out.println(pageSize);
}catch(Exception e){
System.out.println("错误2");
}
%>
<br> function go(num){<br> document.getElementById("cp").value = num;<br> document.spform.submit();<br> }<br>
雇员列表
>
<%
for (int x=1; x<=pageSize; x++){
%>
<%
for (int x=0; x %>
编号 | 姓名 | 工作 | 日期 | 工资 |
<%=no %> | <%=name %> | <%=job %> | <%=date %> | <%=sal %> |