如何在循环中通过表格提交数据?
我有一种方法可以打印一个具有7列值的表。我希望第五列的数据成为一个链接,当我单击它们时,我会被指向另一个页面,其中有更多有关该特定值的详细信息。
for (int i = 1; i <= col; i++) {
// columnnnames being written
table += "<th>" + firstUpper(rsmd.getColumnName(i)) + "</th>";
}
// close head of table
table += "</tr>" + "</thead>";
// Eigentliche Inhalte werden gefuellt
do {
// Start 1.Row
table += "<tr>";
// For Loop through all values
for (int i = 1; i <= col; i++) {
// if column 5, put in a form
if (i == 5) {
table += "<td>" + "<form method=\"POST\" action=\"seminarDetailansichtServlet\">"
+ "<input type=\"text\" name=\"titel\" value=\"rs.getString(i)\" readonly>" + "<input type=\"submit\" value=\"Detailansicht\">"
+ "</form>" + "</td>";
System.err.print("der kommt an");
} else {
table += "<td>" + rs.getString(i) + "</td>";
}
}
table += "</tr>";
} while (rs.next());
因此,我可以在Seminardetailansicht.jsp中提交我单击的特定值,以获取更多详细信息。但是,当我运行程序时,它在输入字段中显示“ rs.getString(i)”,而不是实际值(title)。 提交价值或我做错了什么可能没有显示实际价值的可能性?
谢谢
I have a method that prints a table with values of 7 columns. I wanted the data of the fifth columns to be a link, that when i click on them i get directed to another page, where I have more details about that specific value.
for (int i = 1; i <= col; i++) {
// columnnnames being written
table += "<th>" + firstUpper(rsmd.getColumnName(i)) + "</th>";
}
// close head of table
table += "</tr>" + "</thead>";
// Eigentliche Inhalte werden gefuellt
do {
// Start 1.Row
table += "<tr>";
// For Loop through all values
for (int i = 1; i <= col; i++) {
// if column 5, put in a form
if (i == 5) {
table += "<td>" + "<form method=\"POST\" action=\"seminarDetailansichtServlet\">"
+ "<input type=\"text\" name=\"titel\" value=\"rs.getString(i)\" readonly>" + "<input type=\"submit\" value=\"Detailansicht\">"
+ "</form>" + "</td>";
System.err.print("der kommt an");
} else {
table += "<td>" + rs.getString(i) + "</td>";
}
}
table += "</tr>";
} while (rs.next());
so I can submit the specific value i clicked on to get more details of it in my seminarDetailansicht.jsp. But when I'm running my program, it shows in the input fields "rs.getString(i)" instead of the real value (title).
Is there another possibility to submit the value or what am I doing wrong that it doesn't show the actual value?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因是
rs.getString(i)
在双引号内部,因此只是字符串的一部分。您想将rs.getString(i)的结果限制到字符串。例如:
“&lt; input type = \“ text \” name = \“ titel \” value = \“” + rs.getString(i) +“ \” \“ \” + ...
The reason is
rs.getString(i)
is inside the double quote so it's just part of a string. You want to concat the result of rs.getString(i) to the string.For example:
"<input type=\"text\" name=\"titel\" value=\"" + rs.getString(i) + "\" + ...