orant 2004年02月14日
100分的JSP问题(有代码):如果解决,可以再补分
出错页面:
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%>
<html>
<head>
<link rel='stylesheet' type='text/css' href='inc/FORUM.CSS'>
<META NAME="keywords" CONTENT="渊源河海论坛 java forum jsp forum">
<META NAME="description" CONTENT="渊源河海论坛 java forum jsp forum">

<title>论谈</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body text="#0000ff" >
<jsp:include page="inc/public.jsp" flush="true"/>
<table width="760" cellspacing="0" cellpadding="0" align="center">
<tr>
<jsp:useBean id="yy" scope="page" class="yy.jdbc"/>
<jsp:useBean id="li" scope="page" class="yy.bbcode"/>
<%! String Board_Name,Board_Id,Note_Id;%>
<%
Board_Id=request.getParameter("fid");
Note_Id=request.getParameter("noteid");
Connection con=yy.getConn();
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=null;
String sql="Select forum_name from forum Where forum_id="+Board_Id;
rs=stmt.executeQuery(sql);
while(rs.next())
{
Board_Name=rs.getString("forum_name");
}
%>
<td width="62%"> <a href="../default1.jsp">首页</a>>><a href="index.jsp">论坛</a>>><a href=board.jsp?fid=<%=Board_Id%>><%=Board_Name%></a>>>浏览贴子
</td>
<td class="post" align="right" width="38%"> <a href="post.jsp?fid=<%=Board_Id%>"><img src="IMAGES/TOPIC.GIF" border="0"></a> <a href="post.jsp?fid=<%=Board_Id%>&Returnid=<%=Note_Id%>"><img src="IMAGES/REPLY.GIF" border="0" ></a> <a href='javascript:print()'><img src="IMAGES/PRINT.GIF" border="0" ></a></td>
</tr></table>

<table cellspacing="0" cellpadding="0" border="0" width="754" align="center">

<tr>
<td bgcolor="#009ACE">
<table border="0" cellspacing="1" cellpadding="6" width="100%">
<%
sql="update article set click_num=click_num+1 where article_id="+Note_Id;
stmt.executeUpdate(sql);

int PageSize=10;
int RecordCount=0;
int PageCount=0;
int ShowPage=1;
sql="Select * from common_user,article where article.article_author=common_user.username And article.article_id="+Note_Id+" And forum_id="+Board_Id+" or article.article_author=common_user.username And article.reply_id="+Note_Id+" And forum_id="+Board_Id+" order by article.article_id";
rs=stmt.executeQuery(sql);
while(rs.next()){
RecordCount=RecordCount+1;
}
PageCount=(RecordCount % PageSize==0)?(RecordCount/PageSize):(RecordCount/PageSize+1);
String Page=request.getParameter("page");
if (Page!=null)
{
ShowPage=Integer.parseInt(Page);
if (ShowPage>PageCount)
ShowPage=PageCount;
else if(ShowPage<0)
ShowPage=1;
}else
ShowPage=1;

if (RecordCount>0)
{
rs.absolute((ShowPage-1)*PageSize+1);

String Note_Title="";
String User_Name="";

String Noteall_Id="";
String User_Level="";
String Sing_Id="";

for (int i=1;i<PageSize;i++)
{
System.out.println(rs.getRow());
Note_Title=rs.getString("article_name");
System.out.println(Note_Title);

User_Name=rs.getString("username");

Noteall_Id=rs.getString("article_id");
User_Level=rs.getString("userlevel");
Sing_Id=rs.getString("show_signature");
%>

<tr>
<td width="22%" bgcolor="#9CCFFF">作者: <%=User_Name%></td>
<td bgcolor="#9CCFFF">文章标题: <%=Note_Title%></td>
</tr>
<tr>
<td rowspan="3" valign="top" bgcolor="#F7FBFF"><br />
<br /><div><center>
<img src="./<%=rs.getString("user_pic")%>"><br />
<br />
<%=User_Level%><br />
<br /><br /></center><br />
贴子数量 :<%=rs.getString("post_articlenum")%> <br />
注册日期 :<%=rs.getString("reg_time").substring(0,10)%></div>
</td>
<td valign="top" bgcolor="#F7FBFF"><img src="IMAGES/<%=rs.getString("article_picture")%>.GIF" />
  发表于:<%=rs.getString("post_time").substring(0,16)%></td>
</tr>
<tr>
<td height="120" valign="top" bgcolor="#F7FBFF"><%=li.yyBBCODE(li.HTMLEncode(rs.getString("article_content")))%>
<%
if ((Sing_Id!=null)&&Sing_Id.equals("1"))
out.println("<hr size=1 color=#000000 noshade>签名<br>  "+li.yyBBCODE(li.HTMLEncode(rs.getString("signature"))));


%>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#F7FBFF">
<table border="0" cellspacing="0" cellpadding="0" align="left" width="378" height="20">
<tr>
<td><a href="member.jsp?member=<%=User_Name%>"><img src="IMAGES/PROFILE.GIF" border="0" alt="查看此人的个人资料" width="45" height="18"></a>
<a href="mailto:<%=rs.getString("email")%>"><img src="IMAGES/EMAIL.GIF" border="0" alt="发送E-Mail给此人" width="45" height="18" /></a>
<a href="post.jsp?fid=<%=Board_Id%>¬eid=<%=Noteall_Id%>&returnid=<%=Note_Id%>"><img src="IMAGES/QUOTE.GIF" border="0" alt="引用回复" width="45" height="18" /></a>
<a href="article.jsp?member=<%=rs.getString("username")%>"><img src="IMAGES/FIND.GIF" border="0" alt="搜索此人的所有贴子" width="45" height="18"></a>

<a href="edit.jsp?fid=<%=Board_Id%>¬eid=<%=Note_Id%>&editid=<%=Noteall_Id%>"><img src="IMAGES/EDIT.GIF" border="0" alt="编辑贴子" width="47" height="18" /></a>
<a href="querymodify.jsp?fid=<%=Board_Id%>&deleteid=<%=Noteall_Id%>"><img src="IMAGES/DELETE.GIF" onclick="{if(confirm('确定删除选定的纪录吗?')){return true;}return false;}" width="45" height="18" alt="删除贴子" border="0"></a>
<%
//End If
%>
</td>
</tr>
</table>
</td>
</tr>

<%
if (!rs.next())
break;
}
}
%>

</table>
</td></tr>
</table>

<table width="733" cellspacing="0" cellpadding="0" align="center" height="20">
<tr bgcolor="#ffffff">
<td class="post" valign="top" width="547" height="6">  <a href='javascript:print()'><img src="IMAGES/PRINT.GIF" border="0" ></a> <a href="post.jsp?fid=<%=Board_Id%>&Returnid=<%=Note_Id%>"><img src="IMAGES/REPLY.GIF" border="0" ></a> <a href="post.jsp?fid=<%=Board_Id%>"><img src="IMAGES/TOPIC.GIF" border="0"></a></td>
<td align="right" width="182" height="6">

<form method="POST" action="shownote.jsp">
<p><input type="hidden" name="fid" size="20" value='<%=Board_Id%>'></p>
<p><input type="hidden" name="noteid" size="20" value='<%=Note_Id%>'></p>
<p><input type="hidden" name="boardname" size="20" value='<%=Board_Name%>'></p>
<p>
现在是第 <font color=black ><%=ShowPage%></font> 页 转到<select size="1" name="page">
<%
for (int i=1;i<=PageCount;i++)
{
out.println(" <option value="+i+">"+i+"页</option>");
}
%></select>
<input type="submit" value="go" name="B1">
</form>

</td></tr>
<jsp:include page="inc/jumpboard.jsp" flush="true"/>
</table>
</body></html>

<jsp:include page="inc/online.jsp" flush="true"/>
<%
try {
rs.close();
stmt.close();
con.close();
}
catch (Exception ex) {
}
%>
...全文
26 点赞 收藏 7
写回复
7 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告