如何创建 JSP 页表并记录操作
我对 JSP/JSTL 还不太了解,所以我需要一些帮助。我的网页设计看起来像
=========================================== =============
= 姓名 SSN 地址 =
= =
= =
= 添加行 =
=================================================== ====
当用户单击“添加行”时,一个新行将添加到表中。用户输入一些内容,然后单击“添加行”。向我展示的示例使用 scriptlet“这里的代码非常旧”。我想使用 JSTL foreach 构造并迭代该构造。渲染列表后,如何将用户输入的值存储到我拥有的元素中? Foreach 构造似乎只适合渲染,或者我错了。任何教程或示例...
I am bit green on JSP/JSTL so I need a little bit of help. I have a web page design that looks like
======================================================
= Name SSN Address =
= =
= =
= Add Row =
======================================================
As user clicks on "Add Row", a new row is added to the table. The user types in some stuff and then, clicks on Add Row. The examples shown to me, uses scriptlets "code over here is really old". I would like to use JSTL foreach construct and iterate over the construct. After the list is rendered, how do I store the values user typed into the element I have ? Foreach construct seems only good for rendering or am I mistaken. Any tutorials or examples...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来,尽管我在问这个问题之前已经研究过这个问题,但我还是被否决了。简单的答案是,你不能。但是有两种解决方案;我脑子里想出了两个;
-- 对于输入的记录,您的表是静态的。您可以简单地循环 bean 并显示输入的内容,并给它们一个按钮来删除一行(如果它们愿意)。最后一行是动态的并且具有输入标签。
-- 您重写每个输入元素的 id,例如第 2 行的 name1、ssn1、address1、name2、ssn2、address2。这使用户可以更新他们想要的任何行上的任何字段。然而,在我看来,它很丑陋,我喜欢第一个解决方案,所以我将继续我想到的第一个解决方案......
Looks like, I have been downvoted even though I have researched the question before asking this. Simple answer is this, you can not. However there are two solutions; I came up with two in my head;
-- your table is static for the entered records. U can simply loop over the beans and display what's entered and give them a button to remove a row if they want to. The last row is dynamic and has the input tags.
-- you rewrite the ids of each input element such as name1, ssn1, address1, name2, ssn2, address2 for row 2. This gives the user to update any field on any row they want. However it is butt ugly in my opinion and I like the first solution so I will go ahead with the first solution I have in mind....