使用Java和Rows迭代表时丢失数据联合应用程序
在jsp页面中,根据记录的数量,会执行这个tr并显示给用户。
for(int i=0; i<NoOfRecords.length;i++){
<tr>
<td width="15%"> Transit Account & <%= acctId%>
</td>
<td width="15%"> <%=MultiModeConstants.GL_ACCT_NO%>
</td>
<td width="45%">
<input type="text" id="multiModeAcctNo" name="multiModeAcctNo" desc="Multi Mode Transit Account Number" maxlength="9" class="body" size="9" tabindex="3" >
</td>
<td width="15%">
Deposit
</td>
<td width="15%">
$ <%= transactioAmount%>
</td>
</tr>
}
根据记录数,在jsp页面中填充行数, multiModeAcctNo,字段将由用户输入(multiModeAcctNo);
例如,如果有4条记录,则我在页面中输入不同的multiModeAcctNo 4次。
提交页面后,我只能获取第一个字段,我丢失了其他 3 个值。
假设如果我只读取一行,那么我就能很好地获取数据。我需要做什么?
我正在使用 java & jsp作为编程语言。
In the jsp page, depending on the number of records, this tr will be executed and displayed to the users.
for(int i=0; i<NoOfRecords.length;i++){
<tr>
<td width="15%"> Transit Account & <%= acctId%>
</td>
<td width="15%"> <%=MultiModeConstants.GL_ACCT_NO%>
</td>
<td width="45%">
<input type="text" id="multiModeAcctNo" name="multiModeAcctNo" desc="Multi Mode Transit Account Number" maxlength="9" class="body" size="9" tabindex="3" >
</td>
<td width="15%">
Deposit
</td>
<td width="15%">
$ <%= transactioAmount%>
</td>
</tr>
}
Based on the number of records, Number of rows would be populated in the jsp page,
multiModeAcctNo, field will be entered by User(multiModeAcctNo);
For example if there are 4 records, there are 4 times I enter different multiModeAcctNo in the page.
After submitting the page, I am able to get only the first field, I am losing the other 3 values.
Suppose if I only read One Row, then I am able to get the data fine. What do I need to do?
I am using java & jsp as the programming languages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须为输入字段创建动态名称,可能如下:
现在在您的 servlet 中[希望您也能在那里获得 NoOfRecords.length] 通过提供动态生成的名称来获取每个输入的值。可能是这样的:
You have to create dynamic names for input fields may be as:
Now in your servlet [hoping that you also get NoOfRecords.length there] get value of each input by providing it's dynamically generated names. May be as:
我不确定您正在执行哪种提交,但您可能希望为输入字段使用不同的 ID,因为您在迭代时在
< 中使用相同的
。multiModeAcctNo
ID ;输入>如果您使用表单并 POST 元素,您可能需要将
input
命名为multiModeAcctNo[]
之类的名称,然后在 JSP 文件中将其作为 POST 数组元素引用(不确定 Java 是否可以实现)。只是一个想法。I'm not sure what kind of submission you're doing but you may want to use a different ID for your input field, as you iterate you are using the same
multiModeAcctNo
ID in your<input>
.If you're using a form and POSTing the element you may want to name your
input
to something likemultiModeAcctNo[]
then in your JSP file refer it as a POST array element (not sure if that's possible with Java). Just an idea.