<%!private void tree(Set<Article> articles, Connection con, int id, int grade) {
String sql = "select * from article where pid = " + id;
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt, sql);
try {
while (rs.next()) {
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setRootId(rs.getInt("rootid"));
a.setTitle(rs.getString("title"));
a.setLeaf(rs.getInt("isleaf") == 0 ? true : false);
a.setPdate(rs.getTimestamp("pdate"));
a.setGrade(grade + 1);
articles.add(a);
if (!a.isLeaf()) {
tree(articles, conn,a.getId(), grade + 1);
} }
} catch (SQLException e) {
e.printStackTrace();
}
}%><%
Set<Article> articles = new HashSet<Article>();
Connection conn = DB.getConn();
tree(articles, conn, 0, 0);
DB.close(conn);
%>不太会提问,我是跟着尚学堂BBS2007做下来的,其中在树状结构展现1的视频中,遇到上述问题,出现红色字体,有错误,报错如下:
严重: Error compiling file: /C:/Program Files/Apache Software Foundation/Tomcat 5.0/work/Catalina/localhost/ShoolWeb//org/apache/jsp\bbs_jsp.java     [javac] Compiling 1 source fileC:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\ShoolWeb\org\apache\jsp\bbs_jsp.java:16: 找不到符号
符号: 变量 conn
位置: 类 org.apache.jsp.bbs_jsp
Statement stmt = DB.createStmt(conn);
                               ^
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\ShoolWeb\org\apache\jsp\bbs_jsp.java:30: 找不到符号
符号: 变量 conn
位置: 类 org.apache.jsp.bbs_jsp
tree(articles, conn,a.getId(), grade + 1);
               ^
2 错误我按照视频做的 ,其他的也封装好了,找不出问题,求助高手了~~~~~

解决方案 »

  1.   

    Connection con,  Statement stmt = DB.createStmt(conn);对比一下,con == conn ?
      

  2.   

    private void tree(Set <Article> articles, Connection conn, int id, int grade) 
      

  3.   

    谢谢1楼,Conn 搞定了,可 Set <Article> articles = new HashSet <Article>();  还是红的 这个好像就不是拼写问题了,请教啊 ~~~~谢谢
      

  4.   

    谢谢1楼,Conn 搞定了,可 Set <Article> articles = new HashSet <Article>();  还是红的 这个好像就不是拼写问题了,请教啊 ~~~~谢谢
      

  5.   

    Set articles = new HashSet(); 
      

  6.   

    <>是JAVA中的范型,可以说是JAVA5.0中引入的新特性,你可以先去复习下,详细的资料可以看http://www.360doc.com/content/090721/11/181736_4369612.html
      

  7.   

    把泛型去掉,看看还报不报错,楼主貌似要好好学习一下java基础
      

  8.   

    楼主如果是在jdk1.5下这样用是没有问题的!如果是在jdk1.6下就会有问题了!
    详情请看:http://topic.csdn.net/u/20070105/13/e5941eda-b30f-416e-9e8b-c4c5c84883a3.html
      

  9.   

    谢谢,我JDK是1.6的,我把泛型去掉,虽然不出小红线了,可是运行还有错误,怎么搞的