jsp在Eclipse里加超链接无反应,请教各位

08-08-10 sway
源代码如下:

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

pageEncoding="gbk"%>

<%@ 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='ShowArticleDetails.jsp?id=" + rs.getInt("id") + "'>" +

rs.getString("title") +

"</a><td>" +

"<a href='Delete.jsp?id=" + rs.getInt("id") +"&pid=" +

rs.getInt("pid") + "'>Delete</td></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:3306/bbs";

Connection conn = DriverManager.getConnection(url,"root","root");

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='ShowArticleDetails.jsp?id=" + rs.getInt("id") + "'>" +

rs.getString("title") +

"</a><td>" +

"<a href='Delete.jsp?id=" +

rs.getInt("id") + "&pid=" +rs.getInt("pid") +"'>Delete</a></td>" +

"</td></tr>";

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

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

}

}

rs.close();

stmt.close();

conn.close();

%>

<html>

<head>

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

<title>Show Article Tree</title>

</head>

<body>

<a href="Post.jsp">Post new subject</a> // 我想在此处加一个链接,但怎么加都没反应

<table border="2"> // 忙活了我一下午

<%= str %>

<% str = ""; %>

</table>

</body>

</html>

麻烦如上文,本人系新手一个,求大家帮助帮助。

sway
2008-08-10 19:21
我先顶一个

hellohong
2008-08-11 09:32
将其在页面上输出的html给拷贝下来, 放到DW或者别的编辑器上, 分析一下即可,

猜你喜欢