我有一種方法可以列印一個包含 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)”而不是實際值(標題)中。是否有另一種提交值的可能性,或者我做錯了什么,它沒有顯示實際值?
謝謝
uj5u.com熱心網友回復:
原因是rs.getString(i)
在雙引號內,所以它只是字串的一部分。您想將 rs.getString(i) 的結果連接到字串。
例如:
"<input type=\"text\" name=\"titel\" value=\"" rs.getString(i) "\" ...
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/496800.html
上一篇:從佇列中獲取特定元素
下一篇:如何訪問其他類的變數