我有幾個#foreach的#如果我在Velocity模板組合瑪吉後我面臨的格式問題如下模板:Velocity模板格式問題
模板:
#if ($rq.allowanceType == "TAXI")
#foreach($i in [1..50])
#set($test = "$rq.subType$i")
#if($render.eval($ctx, "$rq.subType$i") != "" && $test != $render.eval($ctx, "$rq.subType$i"))
<aps:lineItem>
<aps:details>
<aps:type>$render.eval($ctx, "$rq.type$i")</aps:type>
<aps:billNumber>$render.eval($ctx, "$rq.billNumber$i")</aps:billNumber>
<aps:isReceived>$render.eval($ctx, "$rq.valid$i")</aps:isReceived>
#if($render.eval($ctx, "$rq.valid$i") == "YES")
<aps:FromDate>$render.eval($ctx, "$rq.FromDate$i")</aps:FromDate>
<aps:ToDate>$render.eval($ctx, "$rq.ToDate$i")</aps:ToDate>#end#if($render.eval($ctx, "$rq.Amount$i") != "")<aps:Amount>$render.eval($ctx, "$rq.Amount$i")</aps:Amount>#end#if($render.eval($ctx, "$rq.VatAmount$i") != "")<aps:VatAmount>$render.eval($ctx, "$rq.VatAmount$i")</aps:VatAmount>
#end
<aps:GrossAmount>$render.eval($ctx, "$rq.GrossAmount$i")</aps:GrossAmount>
</aps:details>
</aps:lineItem>
#end
#end
#end
格式爲
<aps:lineItem>
<aps:details>
<aps:type>FRAMES</aps:type>
<aps:billNumber>695</aps:billNumber>
<aps:isReceived>YES</aps:isReceived>
<aps:FromDate>01/02/1993</aps:FromDate>
<aps:ToDate>01/02/1994</aps:ToDate> <aps:GrossAmount>3000</aps:GrossAmount>
</aps:details>
</aps:lineItem>
<aps:lineItem>
<aps:details>
<aps:type>TEST</aps:type>
<aps:billNumber>695</aps:billNumber>
<aps:isReceived>NA</aps:isReceived>
<aps:GrossAmount>3000</aps:GrossAmount>
</aps:details>
</aps:lineItem>
在速度模板中添加條件和循環時應該注意什麼,以避免造成格式問題?