UserResult.jsp:<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@page import="java.util.*,
sql.dao.*,
sql.dao.impl.*,
sql.model.*"
%>
<%
request.setCharacterEncoding("GBK");
Table table = new Table();
TableDao tableDao = new TableDaoImpl();
ArrayList userList = (ArrayList)request.getAttribute("ulist");
System.out.println("userList.size(): " + userList.size());
String tableid = request.getParameter("tableid");
//System.out.println("tableid: " + tableid);
int PageSize = 10; //一页显示的记录数
//int RowCount = tableDao.getUserRecordCount(); //记录总数
int RowCount = userList.size(); //记录总数
System.out.println("RowCount: " + RowCount);
int PageCount = (RowCount+PageSize -1)/PageSize;//总页数
int Page;//当前页
String strPage = request.getParameter("p");
//System.out.println("p: " + strPage);
if(strPage==null){
Page = 1;
}
else{
Page = Integer.parseInt(strPage);
if(Page<1) Page = 1;
}
if(Page>PageCount) Page = PageCount;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<p><strong>SQL Tool</strong></p>
<p>Please Type Your SQL Statement In The Following Box:<br />
</p>
<form id="form1" name="statement" method="post" action="">
<p><label>
<textarea name="textarea" id="textarea" cols="45" rows="8"></textarea> </label>
</p>
<input type="submit" name="submit" value="提交" />
<input name="reset" type="reset" value="重置" />
</form><hr />
<table width="660" height="77" border="1">
<tr>
<th colspan="5" scope="col">Table User Details</th>
</tr>
<tr>
<td width="35"><div align="center"><strong>Id</strong></div></td>
<td width="148"><div align="center"><strong>FirstName</strong></div></td>
<td width="152"><div align="center"><strong>LastName</strong></div></td>
<td width="153"><div align="center"><strong>UserName</strong></div></td>
<td width="138"><div align="center"><strong>Password</strong></div></td>
</tr>
</tr>
<%
if(PageCount>0){
int i = (Page-1)*PageSize;
System.out.println(i);
System.out.println((Page-1)*PageSize+PageSize);
System.out.println(RowCount);
while(i<((Page-1)*PageSize+PageSize)&&i<RowCount){
//System.out.println("userList.size()2 : " + userList.size());
User user=(User)userList.get(i);
//user.getUserInfo();
%>
<tr>
<td align="center" ><%=user.getId() %></td>
<td align="center" ><%=user.getFirstname() %></td>
<td align="center" ><%=user.getLastname() %></td>
<td align="center" ><%=user.getUsername() %></td>
<td align="center" ><%=user.getPassword() %></td>
</tr>
<%
i ++;
}
}
%>
</table>
<p align="justify"><a href="UserResult.jsp?tableid=<%=tableid %>&p=<%=Page-1%>">上一页</a> <a href="UserResult.jsp?tableid=<%=tableid %>&p=<%=Page+1%>">下一页</a></p>
</body>
</html>控制台打印:userList.size(): 18
RowCount: 18
0
10
18
点击下一页,出现404错误:type Status reportmessage /SqlTool/sql.dao.impl/UserResult.jspdescription The requested resource (/SqlTool/sql.dao.impl/UserResult.jsp) is not available.
<%@page import="java.util.*,
sql.dao.*,
sql.dao.impl.*,
sql.model.*"
%>
<%
request.setCharacterEncoding("GBK");
Table table = new Table();
TableDao tableDao = new TableDaoImpl();
ArrayList userList = (ArrayList)request.getAttribute("ulist");
System.out.println("userList.size(): " + userList.size());
String tableid = request.getParameter("tableid");
//System.out.println("tableid: " + tableid);
int PageSize = 10; //一页显示的记录数
//int RowCount = tableDao.getUserRecordCount(); //记录总数
int RowCount = userList.size(); //记录总数
System.out.println("RowCount: " + RowCount);
int PageCount = (RowCount+PageSize -1)/PageSize;//总页数
int Page;//当前页
String strPage = request.getParameter("p");
//System.out.println("p: " + strPage);
if(strPage==null){
Page = 1;
}
else{
Page = Integer.parseInt(strPage);
if(Page<1) Page = 1;
}
if(Page>PageCount) Page = PageCount;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<p><strong>SQL Tool</strong></p>
<p>Please Type Your SQL Statement In The Following Box:<br />
</p>
<form id="form1" name="statement" method="post" action="">
<p><label>
<textarea name="textarea" id="textarea" cols="45" rows="8"></textarea> </label>
</p>
<input type="submit" name="submit" value="提交" />
<input name="reset" type="reset" value="重置" />
</form><hr />
<table width="660" height="77" border="1">
<tr>
<th colspan="5" scope="col">Table User Details</th>
</tr>
<tr>
<td width="35"><div align="center"><strong>Id</strong></div></td>
<td width="148"><div align="center"><strong>FirstName</strong></div></td>
<td width="152"><div align="center"><strong>LastName</strong></div></td>
<td width="153"><div align="center"><strong>UserName</strong></div></td>
<td width="138"><div align="center"><strong>Password</strong></div></td>
</tr>
</tr>
<%
if(PageCount>0){
int i = (Page-1)*PageSize;
System.out.println(i);
System.out.println((Page-1)*PageSize+PageSize);
System.out.println(RowCount);
while(i<((Page-1)*PageSize+PageSize)&&i<RowCount){
//System.out.println("userList.size()2 : " + userList.size());
User user=(User)userList.get(i);
//user.getUserInfo();
%>
<tr>
<td align="center" ><%=user.getId() %></td>
<td align="center" ><%=user.getFirstname() %></td>
<td align="center" ><%=user.getLastname() %></td>
<td align="center" ><%=user.getUsername() %></td>
<td align="center" ><%=user.getPassword() %></td>
</tr>
<%
i ++;
}
}
%>
</table>
<p align="justify"><a href="UserResult.jsp?tableid=<%=tableid %>&p=<%=Page-1%>">上一页</a> <a href="UserResult.jsp?tableid=<%=tableid %>&p=<%=Page+1%>">下一页</a></p>
</body>
</html>控制台打印:userList.size(): 18
RowCount: 18
0
10
18
点击下一页,出现404错误:type Status reportmessage /SqlTool/sql.dao.impl/UserResult.jspdescription The requested resource (/SqlTool/sql.dao.impl/UserResult.jsp) is not available.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货