将 Map 渲染到 freemarker 模板表时出现错误。下面是我从控制器获得的带有实际值的地图。
Map<Object, Object> hramonths ={4={id=4, empjoindate=16 Nov 2007, description=Apr-2012, editable=T}, 5={id=5, empjoindate=16 Nov 2007, description=May-2012, editable=T}, 6={id=6, empjoindate=16 Nov 2007, description=Jun-2012, editable=T}, 7={id=7, empjoindate=16 Nov 2007, description=Jul-2012, editable=T}, 8={id=8, empjoindate=16 Nov 2007, description=Aug-2012, editable=T}, 9={id=9, empjoindate=16 Nov 2007, description=Sep-2012, editable=T}, 10={id=10, empjoindate=16 Nov 2007, description=Oct-2012, editable=T}, 11={id=11, empjoindate=16 Nov 2007, description=Nov-2012, editable=T}, 12={id=12, empjoindate=16 Nov 2007, description=Dec-2012, editable=T}, 1={id=1, empjoindate=16 Nov 2007, description=Jan-2013, editable=T}, 2={id=2, empjoindate=16 Nov 2007, description=Feb-2013, editable=T}, 3={id=3, empjoindate=16 Nov 2007, description=Mar-2013, editable=T}}
从我的控制器现在我想将此值呈现给我的 freemarker 模板,例如
<#list hramonths as indication>
<tr>
<td class="center">
<#list monthlyrent as rent>
<#if indication.id == rent.month><input type="hidden" name="locationIndicatorId_${indication.id}" value="${indication.id}" /> </#if>
</#list>
</td>
<td class="center">
${indication.description} <input type="hidden" name="month_${indication.id}" id="month_${indication.id}" value="${indication.id}" />
</td>
<td class="center">
<# assign varIndicatorId ="">
<#list monthlyrent as rent>
<#if indication.id == rent.month>
<# assign varIndicatorId = ${rent.Indicator}>
</#if>
</#list>
<select name="indicator_${indication.id}" <#if indication.editable == "F"> disabled="true" </#if> <#if editable == false>disabled="true"</#if>>
<#list indicators as indicator>
<option value="${indicator.cid}" <#if indicator.cid == varIndicatorId> selected </#if>>
${indicator.description}
</option>
</#list>
</select>
</td>
<td class="right">
<#if mothlyrentsize != "0">
<#list monthlyrent as rent>
<#if indication.id == rent.month>
<input type="text" align="right" name="rent_${indication.id}_${rent.cid}"
value="$DelphiNumber.formatNumber("$!rent.rent")"
<#if indication.editable == "F">
readonly="true" class="rbox" </#if>
<#if editable == false>
readonly="true" class="rbox"
</#if>
<#if indication.editable != "F" && editable != false>
onBlur="isnumeric(this.form,this),updateHRATotalAll(this.form,'blurtype')"
</#if> />
</#if>
</#list>
<#else>
<input type="text" name="rent_${indication.id}_0" value="$DelphiNumber.formatNumber("0")"
#if("$!indication.editable" == "F")
readonly="true" class="rbox" #end
#if($editable == false)
readonly="true" class="rbox"
#end
style="TEXT-ALIGN: right"
#if("$!indication.editable" != "F" && $editable != false)
onBlur="isnumeric(this.form,this),updateHRATotalAll(this.form,'blurtype')"
#end >
</input>
</#if>
</td>
</tr>
</#list>
但我收到错误
Expected collection or sequence. hramonths evaluated instead to freemarker.template.SimpleHash on line 199, column 40 in WEB-INF/classes/com/greytip/cougar/module/epayroll/v2/freemarker/salary/it-declaration.ftl. The problematic instruction: ---------- ==> list hramonths as indication [on line 199, column 33 in WEB-INF/classes/com/greytip/cougar/module/epayroll/v2/freemarker/salary/it-declaration.ftl] ---------- Java backtrace for programmers: ---------- freemarker.template.TemplateException: Expected collection or sequence. hramonths evaluated instead to freemarker.template.SimpleHash on line 199, column 40
我如何将它呈现在桌子上,请任何人帮助我。