我现在调试不了,看程序太费劲。给你一个好使的吧,都用在网站了:)
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=gb2312"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言列表</title>
<script language='javascript' src="/header.js"></script>
</head><body topmargin="2" leftmargin="0" bgcolor="#000000" >
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="343">
<tr>
<td width="15%" height="343" valign="top" background="../imgs/leftback.gif">
<p align="center"> </p>
<div align="center">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="center">
<p align="right"><a href="/support/index.jsp">
<<<返回</a></p>
</td>
</tr>
<center>
<tr>
<td width="100%" align="center"></td>
</tr>
<tr>
<td width="100%" align="center"></td>
</tr>
<tr>
<td width="100%" align="center"></td>
</tr>
</table>
</center>
</div>
</td>
<td width="85%" height="343" valign="top" background="../imgs/gstbk.jpg"><div align="center">
<br><center>
<table border="0" width="88%" cellspacing="0" cellpadding="0">
<tr>
<td width="97%" colspan="2">
</td>
<td width="3%">
</td>
</tr>
<tr>
<td width="97%" colspan="2">
<%
String drivername="sun.jdbc.odbc.JdbcOdbcDriver";
String dbUrl="jdbc:odbc:edusoft";
//-------------------------------------------
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i; //设置一页显示的记录数
intPageSize = 12; //取得待显示页码
strPage = request.getParameter("page");
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
//-------------------------------------------------------------
try
{
Class.forName(drivername);
Connection conn=DriverManager.getConnection(dbUrl,"sa","");
Statement stm = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stm.executeQuery("select top 120 * from guestbook order by thetime desc");
rs.last();
intRowCount = rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount)
intPage = intPageCount;
out.println("<table align=center width='92%' rules=rows border=1 cellspacing=0 cellpadding=2 bordercolorlight=black bordercolordark=white>");
out.println("<tr>");
%>
<td colspan=3 bgcolor="#50A503">页数:<%=intPage%>/<%=intPageCount%> <%if (intPage<intPageCount) {%><a href="displaymsg.jsp?page=<%=intPage+1%>">下一页</a><%}%> <%if(intPage>1){%><a href="displaymsg.jsp?page=<%=intPage-1%>">上一页 <%}%></a></td><td bgcolor="#50A503">[<a href="index.jsp">发表意见</a>]</td>
<%
out.println("</tr>");
out.println("<tr>");
out.println("<td></td><td><b>主题</b></td><td><b>发言人 </b></td><td><b>发言时间</b></td></tr>");
i=0;
if(intPage==1)
rs.beforeFirst();
else
rs.absolute(intPageSize*(intPage-1));
while(i<intPageSize && rs.next())
{
String theid=rs.getString(1);
String thename=rs.getString(2);
String thetitle=rs.getString(5);
String thetime=rs.getString(7);
%>
<tr><td width='5%'><img src='imgs/circle.gif'></td><td width='50%'><a href="javascript:void(window.open('viewmsg.jsp?theid=<%=theid%>&type=msg','查看留言',' width=600, top=20, left=100, toolbar=no, menubar=no,scrollbars=auto,location=no, status=no'))"><%=thetitle%></a></td><td width='20%'><%=thename%></td><td width='25%'><%=thetime%></td></tr>
<%
i++;
}
out.println("</table>");
rs.close();
conn.close();
}
catch(Exception e)
{
}
%>
<td width="3%">
</td>
<tr>
<td width="2%">
</td>
<td width="95%">
</td>
<td width="3%">
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table><script language='javascript' src="/bottom.js"></script>
</body></html>
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=gb2312"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言列表</title>
<script language='javascript' src="/header.js"></script>
</head><body topmargin="2" leftmargin="0" bgcolor="#000000" >
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="343">
<tr>
<td width="15%" height="343" valign="top" background="../imgs/leftback.gif">
<p align="center"> </p>
<div align="center">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="center">
<p align="right"><a href="/support/index.jsp">
<<<返回</a></p>
</td>
</tr>
<center>
<tr>
<td width="100%" align="center"></td>
</tr>
<tr>
<td width="100%" align="center"></td>
</tr>
<tr>
<td width="100%" align="center"></td>
</tr>
</table>
</center>
</div>
</td>
<td width="85%" height="343" valign="top" background="../imgs/gstbk.jpg"><div align="center">
<br><center>
<table border="0" width="88%" cellspacing="0" cellpadding="0">
<tr>
<td width="97%" colspan="2">
</td>
<td width="3%">
</td>
</tr>
<tr>
<td width="97%" colspan="2">
<%
String drivername="sun.jdbc.odbc.JdbcOdbcDriver";
String dbUrl="jdbc:odbc:edusoft";
//-------------------------------------------
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i; //设置一页显示的记录数
intPageSize = 12; //取得待显示页码
strPage = request.getParameter("page");
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
//-------------------------------------------------------------
try
{
Class.forName(drivername);
Connection conn=DriverManager.getConnection(dbUrl,"sa","");
Statement stm = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stm.executeQuery("select top 120 * from guestbook order by thetime desc");
rs.last();
intRowCount = rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount)
intPage = intPageCount;
out.println("<table align=center width='92%' rules=rows border=1 cellspacing=0 cellpadding=2 bordercolorlight=black bordercolordark=white>");
out.println("<tr>");
%>
<td colspan=3 bgcolor="#50A503">页数:<%=intPage%>/<%=intPageCount%> <%if (intPage<intPageCount) {%><a href="displaymsg.jsp?page=<%=intPage+1%>">下一页</a><%}%> <%if(intPage>1){%><a href="displaymsg.jsp?page=<%=intPage-1%>">上一页 <%}%></a></td><td bgcolor="#50A503">[<a href="index.jsp">发表意见</a>]</td>
<%
out.println("</tr>");
out.println("<tr>");
out.println("<td></td><td><b>主题</b></td><td><b>发言人 </b></td><td><b>发言时间</b></td></tr>");
i=0;
if(intPage==1)
rs.beforeFirst();
else
rs.absolute(intPageSize*(intPage-1));
while(i<intPageSize && rs.next())
{
String theid=rs.getString(1);
String thename=rs.getString(2);
String thetitle=rs.getString(5);
String thetime=rs.getString(7);
%>
<tr><td width='5%'><img src='imgs/circle.gif'></td><td width='50%'><a href="javascript:void(window.open('viewmsg.jsp?theid=<%=theid%>&type=msg','查看留言',' width=600, top=20, left=100, toolbar=no, menubar=no,scrollbars=auto,location=no, status=no'))"><%=thetitle%></a></td><td width='20%'><%=thename%></td><td width='25%'><%=thetime%></td></tr>
<%
i++;
}
out.println("</table>");
rs.close();
conn.close();
}
catch(Exception e)
{
}
%>
<td width="3%">
</td>
<tr>
<td width="2%">
</td>
<td width="95%">
</td>
<td width="3%">
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table><script language='javascript' src="/bottom.js"></script>
</body></html>
解决方案 »
- 关于jsp读取xml的问题
- failed to lazily initialize a collection of role: com.delianghe.entity.Operator.roles, no session or
- apache poi组件获取Excel内容的问题!
- 问问关于设计快速开发平台问题!
- 求助JSP中未定义变量的使用
- JSTL连接数据库的例子
- 问个使用JAVABEAN问题Vector是什么功能?
- 插入数据到数据库的问题
- 还是关于oracle+tomcat+jdbc的问题
- 请大家帮我看一下下面的代码!?
- 简单的JSP问题
- tomcat 与 javabean,高手们,快来拿分吧!
>>>>Connection conn=DriverManager.getConnection(dbUrl,"sa",""); replace the "sa" and "" as your own username and pwd
>>>select top 120 * from guestbook order by thetime desc"); replace this as your own
我邮箱是 [email protected]