如何在循环中通过表格提交数据?

发布于 2025-02-11 05:40:16 字数 1394 浏览 0 评论 0原文

我有一种方法可以打印一个具有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉 2025-02-18 05:40:16

原因是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) + "\" + ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文