2012-04-17 3 views
0

freemarker 템플릿 테이블에 맵을 렌더링하는 동안 오류가 발생했습니다. 아래의 은 컨트롤러에서 실제 값을 가져 오는 맵입니다. 내 컨트롤러에서freemarker 테이블의 렌더링 맵 <String, Object>

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}} 

지금은

<#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 

제발 무엇입니까 아무도 나를 도와주세요.

답변

0

MapList으로 바꿉니다. 당신은지도에서 모든 값을 얻을 수 있습니다

List<Object> hramonths =[ 
    {id=4, empjoindate=16 Nov 2007, description=Apr-2012, editable=T}, 
    {id=5, empjoindate=16 Nov 2007, description=May-2012, editable=T}, 
    {id=6, empjoindate=16 Nov 2007, description=Jun-2012, editable=T}] 

:지도는 키와 같은 문자열보다 다른 것을 사용하는 경우

Collection<Object> hramonthsValues = hramonths.values(); 
0

프리 마커 잘 이해하지 못하는 것처럼 그래서 보인다. Map<Object, Object>Map<String, Object>으로 대체하면 예외가 해결 될 수 있습니다. 그러나 Object를 고유하게 식별하기 위해 "name"속성을 사용할 필요가있을뿐만 아니라 Map의 키로 사용해야합니다.

관련 문제