gpt4 book ai didi

java - 在jsp页面中创建动态行

转载 作者:行者123 更新时间:2023-11-30 07:36:22 25 4
gpt4 key购买 nike

好的...这是一个很长的问题。但我认为答案很简单。虽然我自己找不到解决方案。一个 jsp 页面中没有连续的四列。我想在页面中使用循环再添加 10 行,其中字段的名称如下

row1_amount, row1_loantype,row1_date, row1_status
row2_amount, row2_loantype,row2_date, row2_status

等等。

更清楚

property="cib_borrower_report.loanType" 将出现在表格的所有十行中。

property="cib_borrower_report.loanType1"
property="cib_borrower_report.loanType2"
property="cib_borrower_report.loanType3"

现在如果我想使用循环来命名该怎么做?我如何在属性中添加 1,2,3..???

如果我可以动态地执行此操作,它将帮助我获取值。所以请帮忙。

<table border="0"  cellpadding="1"><tbody>
<tr>
<td ><label class="desc"><bean:message key="label.cib.new.report.taken.amount"/></label></td>
<td><html:text property="cib_borrower_report.takenAmount" styleClass="SingleLineTextField" size="20"></html:text></td>
<td>&nbsp;&nbsp;</td>

<td><label class="desc"><bean:message key="label.cib.new.report.loan.type"/></label></td>
<td><html:text property="cib_borrower_report.loanType" styleClass="SingleLineTextField" size="20"></html:text></td>
<td>&nbsp;&nbsp;</td>

<td><label for="cib_borrower_report.reportingDate" class="desc"><bean:message key="label.cib.new.reporting.date" /></label></td>
<td>
<table><tbody><tr>
<td><input type="Text" name="cib_borrower_report.reportingDate" id="cib_borrower_report.reportingDate" style="cib_borrower_report.reportingDate" class="SingleLineTextField" maxlength="10" size="10" tabindex="1" ></td>

<td><a href="javascript:NewCal('cib_borrower_report.reportingDate','mmddyyyy')"><img align="middle" src="Images/cal.jpg" width="20" height="20" border="0" alt="Pick a date"></a></td>
</tr></tbody></table>
</td>
<td>&nbsp;&nbsp;</td>

<td><label class="desc"><bean:message key="label.cib.new.loan.status"/></label></td>
<td align="center">
<html:select property="cib_borrower_report.loanStatus" styleId="searchQuery1">
<html:option value="STD">STD</html:option>
<html:option value="SMA">SMA</html:option>
<html:option value="SS">SS</html:option>
<html:option value="DF">DF</html:option>
<html:option value="BL">BL</html:option>
</html:select>
</td>
</tr>
</tbody></table>

最佳答案

在 JSP 中 <foreach/>标记您可以使用 varStatus 获取索引属性并将其添加到属性名称中。

<c:forEach var="bean" items="${item}" varStatus="status">  Item: <c:out value="${item}"/>  Item Index: <c:out value="${status.index}"/> <!-- Starts from zero -->  Item Count: <c:out value="${status.count}"/> <!-- Starts from one --></c:forEach>

我建议使用列表而不是命名的属性名称(看起来更好并且扩展了动态方法)。对于列表,您仍然需要遍历输出,但会有一个更简洁的 JSP(一开始就很难看)。

关于java - 在jsp页面中创建动态行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3645092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com