JSP在Eclipse中调试时说 "(" , "," , ")" 编译出错

07-05-05 lxbhxwl
JSP在Eclipse中调试时说 "(" , "," , ")" 编译出错 为什么呀 我是在E文下输入的 ???

private void tree(Connection conn, int id, int level) {

...........

}

标记“,”上有语法错误,应为 ; BBS/WebContent ShowArticleTree.jsp标记“,”上有语法错误,应为 ; BBS/WebContent ShowArticleTree.jsp标记“(”上有语法错误,应为 ; BBS/WebContent ShowArticleTree.jsp标记“)”上有语法错误,应为 ; BBS/WebContent ShowArticleTree.jsp

就是 哪个tree 后边的"()"和里边的","出错,没办法编译运行

急 在线等

>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[该贴被lxbhxwl于2007年05月05日 15:33修改过]

older
2007-05-05 15:39
把相关的代码贴出来可能会比较好点,让人感觉问题更贴近。

lxbhxwl
2007-05-05 16:38
源代码:

<%@ page language="java" contentType="text/html; charset=GB2312"

pageEncoding="GB2312"%>

<%@ page import="java.sql.*" %>

<%!

String str = "";

private void tree (Connection conn,int id,int level) {

Statement stmt = null;

ResultSet rs = null ;

String preStr = "";

for (int i = 0;i <= level;i++){

preStr = "|-->>";

}

try{

stmt = conn.createStatement();

String sql = "select * from article where pid = "+id;

rs = stmt.executeQuery(sql);

while (rs.next()){

str += "<tr><td>"+rs.getInt("id")+"</td><td>"+

preStr + "<a href='ShowArticleDetail.jsp?id="+rs.getInt("id")+"'>"+rs.getString("title")+

"</a>"+"<td></tr>";

if (rs.getInt("isleaf") != 0){

tree (conn,rs.getInt("id"),level+1);

}

}

}catch(SQLException e){

e.printStackTrace();

}finally {

try{

if(rs != null){

rs.close();

rs = null;

}

if(stmt != null){

stmt.close();

stmt = null;

}

}catch(SQLException e){

e.printStackTrace();

}

}

}

%>

<%

Class.forName("com.mysql.jdbc.Driver");

String url = "jdbc:mysql://localhost/bbs?user=root&password=root";

Connection conn = DriverManager.getConnection(url);

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from article where pid = 0");

while (rs.next()){

str += "<tr><td>"+rs.getInt("id")+"</td><td>"+

"<a href='ShowArticleDetail.jsp?id="+rs.getInt("id")+"'>"+rs.getString("title")+

"</a>"+"<td></tr>";

if (rs.getInt("isleaf") != 0){

tree(conn,rs.getInt("id"),1);

}

}

rs.close();

stmt.close();

conn.close();

response.sendRedirect("ShowArticleTree.jsp");

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=GB2312">

<title>BBS</title>

</head>

<body>

<table border = "1">

<%= str %>

<%

str = "";

%>

</table>

</body>

</html>

[该贴被lxbhxwl于2007年05月09日 09:51修改过]

lxbhxwl
2007-05-05 21:22
exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token "(", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ",", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ",", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ")", ; expected

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token "(", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ",", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ",", ; expected

An error occurred at line: 6 in the jsp file: /ShowArticleTree1.jsp

Generated servlet error:

Syntax error on token ")", ; expected

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)

org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

lxbhxwl
2007-05-09 09:51
哎 问题解决了

>>>>>>>>>>>>>>>

就是在新建一个文件 重新输一遍 感觉很郁闷 复制过去还是报错

只有重新写一边才好 不知是什么原因 代码都没变变 !!

猜你喜欢