【发布时间】:2014-04-11 07:09:29
【问题描述】:
我想从db 获取数据并显示在table 中,并且每条记录都应该有一个See Details 的链接,为此我有:
<form name="submitForm" method="POST" action="details.jsp">
<table border="1" width="80%">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>More</th>
</tr>
<%
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
connection = com.secure.db.DatabaseManager.getConnection();
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * from address");
while (resultSet.next()) {
%>
<tr>
<td><%=resultSet.getString("first_name")%> <input type="hidden"
name="fname" value="<%=resultSet.getString("first_name")%>"></td>
<td><%=resultSet.getString("last_name")%> <input type="hidden"
name="lname" value="<%=resultSet.getString("last_name")%>"></td>
<td> <a href="javascript:document.submitForm.submit()">See Details</a></td>
</tr>
<%
}
%>
</table>
<%
} catch (Exception ex) {
ex.printStackTrace();
%>
Ooops, something bad happened:
<%
} finally {
if (resultSet != null)
resultSet.close();
if (statement != null)
statement.close();
if (connection != null)
connection.close();
}
%>
</form>
现在结果是:
当我点击第一条记录时,我得到了正确的信息,但是当我点击第一条记录以外的信息时 我仍在获取第一条记录的数据。如何获取正确的数据?
【问题讨论】:
-
我没有看清楚你的要求,请说清楚。
-
@JqueryLearner 请看我的问题我已经编辑了这个...
标签: java javascript jquery jsp tomcat