【发布时间】:2012-12-05 14:48:18
【问题描述】:
我正在使用 JSP 和 Servlet 开发一个 Web 应用程序。 在该应用程序中,我必须在 html 表中显示来自数据库表 stud(studID, name, add) 的数据,并且表中的每一行在最后一列都有一个与之关联的超链接。单击该超链接后,我想从表中获取(studID)...
到目前为止,我已经从数据库中获取数据,然后将其放入列中,然后为每一行添加超链接。但我无法从与超链接关联的 html 表中获取 (studID)。
提前谢谢....
源代码:
<%
String[][] data = (String[][])request.getAttribute("data");
String[] cNames = (String[])request.getAttribute("columnNames");
//headings
%>
<table>
<tr>
<%
for(int i=0;i<cNames.length;i++) {
%>
<th>
<%= cNames[i] %>
</th>
<%
}
//data if(data!=null)
for(int i=0;i<data.length;i++) {
%>
<tr>
<%
for(int a=0;a<3;a++) {
%>
<td>
<%=
data[i][a]
%>
</td>
<%
//hyperlink
if(a==2) {
%>
<td>
<a href="PlanProtocol" id=<%=i%> onclick="<% session.setAttribute("ID","p2"); %>" >Edit</a></td>
<%
}
}
%>
</tr>
<% } %>
<tr>
</table>
【问题讨论】:
-
如果您向我们展示一些代码,我们将更有能力提供帮助。