好的..。这个问题很长。但我认为答案很简单。虽然我自己找不到解决办法。在jsp页面中将这四列放在一行中。我希望使用页面中的循环再添加10行,其中字段的名称如下
row1_amount, row1_loantype,row1_date, row1_status
row2_amount, row2_loantype,row2_date, row2_status诸若此类。
更清楚
property="cib_borrower_report.loanType"将位于表单中的所有10行中。
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> </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> </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> </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>发布于 2010-09-05 08:07:49
要在JSP页面中执行循环,可以使用JSTL <c:forEach>。您需要下载JSTL的实现,请参阅下面的链接。
资源:
发布于 2010-10-20 20:47:55
在struts逻辑标签库中,您可以使用迭代标记,如Svtruts1.x站点中所记录的那样:
在指定集合上重复此标记的嵌套主体内容。
您的代码上将有以下结构:
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<table><tbody>
<logic:iterate id="formName" name="mycollection">
<tr>
<!-- CONTENT OF EACH ROW -->
</tr>
</logic:iterate>
</tbody></table>对于所需的类交互,可以按其索引访问属性,如下所示:
<logic:iterate id="formName" name="mycollection" indexId="idx">
<html:text name="formName" property='<%= "mycollection[" + idx + "].prop" />' />
</logic:iterate>这将生成一个具有名称属性(如mycollection.prop )的文本字段,如果包含此逻辑的表单被提交,该字段将更新集合mycollection元素的属性支柱。
还请注意,Struts团队鼓励您只在不能使用JSTL标记的情况下使用struts标记,如Struts 1.x站点所述:
注意:这个标签库中的一些特性也可以在JavaServer页面标准标记库(JSTL)中获得。Struts团队鼓励在可能的情况下在Struts特定标记之上使用标准标记。
https://stackoverflow.com/questions/3645092
复制相似问题