怎么我的这个JSP树形目录程序出错
mdot 2003-02-14 11:04:41 <%@ page contentType="text/html;charset=GB2312"%>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.faq"/>
<html>
<head>
<title>无限级菜单测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function expands(expid,picid) //显示图片张合的Js
{ // alert("this.document.all["+expid+"].style.display");
if(this.document.all[expid].style.display=="none")
{ this.document.all[expid].style.display="block";
this.document.all[picid].src="line_01_02.gif";
}
else
{
this.document.all[expid].style.display="none";
this.document.all[picid].src="line_01.gif";
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
try {
ResultSet rs=workM.executeQuery("select * from board1 where parentid=0");
int id=rs.getInt("id");
String boardname=rs.getString("boardname");
}
catch (SQLException e)
{
}
%>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" width="766" bordercolor="#DDCF90" height="392">
<tr>
<td valign="top">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="372">
<tr>
<td width="368"><a onclick="javascript:expands('dwtop','dwimg')" style="cursor:hand"><span align="absmiddle"> <img id="dwimg" SRC="line_01.gif" border="0" align="absmiddle" width="35" height="17"></span></a><font size="2"><a href="tree.jsp?parentid=<%=id%>"><%=boardname%></a></font>
<table id="dwtop" style="display=none" cellspacing="0" cellpadding="0">
<%
ListChildTree(0,0);
%>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
<%!
public void ListChildTree(int parentid,int level){
try {
ResultSet rs=workM.executeQuery("select * from board1 where parentid=0");
String sql="";
while (rs.next())
{
int id=rs.getInt("id");
String boardname=rs.getString("boardname");
int level=rs.getInt("level");
String space="";
for (int j=0;j<level;j++)
Space+=" "; //设置显示节点前面的距离,这里的空格的html被这里自动替换成" "了
int childcount=0;
sql ="select count(*) as childcount from board1 where parentid="+id;//查找孩子节点的孩子节点
try {
ResultSet rs1=workM.executeQuery(sql);
if (rs1.next())
{
childcount=rs1.getInt("childcount");
}
rs1.close();
}
catch (SQLException e){
}
int TableId=childcount; //设置表格Id
int TablePic=childcount; //设置图片Id
if (childcount=0)
{
%>
<tr><td><%=Space%><span align="absmiddle"><img src="line_01_02.gif" border="0" align="absmiddle" width="35" height="17"></span><font size="2"><A href="process.php"><%=rs.getString("boardname")%></a></font>
<table id="<%=TableId%>" style="display=none" cellspacing="0" cellpadding="0">
<%
}
else
{
%>
<tr><td><%=Space%><a onclick="javascript:expands('<%=$TableId%>','<%=$TablePic%>')" style="cursor:hand"><span align="absmiddle"><img id="<%=$TablePic%>" src="line_01.gif" border="0" align="absmiddle" width="35" height="17"></span></a><font size="2"><%=boardname%></a></font>
<table id="<%=TableId%>" style="display=none" cellspacing="0" cellpadding="0">
<%
ListChildTree(id,level);//递归调用函数本身来显示其他孩子节点
}%>
</table>
<%
}
catch (SQLException e)
{
}
}
%>
其中WORKM为一个连接数据库的BEAN。该程序是用来动态从数据库
读取数据形成树形目录,但编译时出错
An error occurred between lines: 69 and 99 in the jsp file: /tree.jsp
Generated servlet error:
D:\jakarta-tomcat-4.0.3\work\localhost\hello1\tree$jsp.java:44: '}' expected.
{
^
D:\jakarta-tomcat-4.0.3\work\localhost\hello1\tree$jsp.java:48: Statement expected.
static {
^
An error occurred between lines: 103 and 107 in the jsp file: /tree.jsp
Generated servlet error:
D:\jakarta-tomcat-4.0.3\work\localhost\hello1\tree$jsp.java:196: 'try' without 'catch' or 'finally'.
else
^
An error occurred between lines: 103 and 107 in the jsp file: /tree.jsp
Generated servlet error:
D:\jakarta-tomcat-4.0.3\work\localhost\hello1\tree$jsp.java:196: 'else' without 'if'.
else
^
An error occurred between lines: 114 and 122 in the jsp file: /tree.jsp
Generated servlet error:
D:\jakarta-tomcat-4.0.3\work\localhost\hello1\tree$jsp.java:260: Type expected.
catch (SQLException e)
^
5 errors
但我看过,好象没错呀?