我试图访问我的对象的属性。但我发现了这个错误。
FreeMarker template error:
The following has evaluated to null or missing
interestRate [in template "interestRate" at line 2, column 8]
在我的代码中,我创建了一个pojoclass对象列表,并使用hasmap映射此列表。
List<InterestRateVO> list = new ArrayList<InterestRateVO>();
Map<String,List<InterestRateVO>> interestRate = new HashMap<String,List<InterestRateVO>> ();
list.add(interestRateVO);
interestRate.put(tableData[1],list);
tableData是我从响应中得到的动态值。这是我的hashmap对象值
{3Y =[com.test.ft.vo.InterestRateVO@18923c7, com.test.ft.vo.InterestRateVO@8c1c27, com.test.ft.vo.InterestRateVO@8c520e], 5Y =[com.test.ft.vo.InterestRateVO@5f48b4, com.test.ft.vo.InterestRateVO@19e3e55, com.test.ft.vo.InterestRateVO@e7bcd]}
这是我的pojoclass
public class InterestRateVO {
private String currency;
private String rate;
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
}
和freemarker模板我使用此代码
<#list interestRate?keys as inter>
${inter} = ${interestRate[inter].currency}
</#list>