Iterating through hashmap in freemarker
I have a hashmap as shown below
HashMap<String, String> testStatus = new HashMap<String, String>();
Map root = new HashMap();
public void fmTest() {
testStatus.put("one","1");
testStatus.put("two","2");
testStatus.put("three","3");
root.put("status", testStatus);
testStatus.clear();
}
My FTL:
<#list status?keys as key>
${key} = ${status[key]}
</#list>
The above code is just an example. My question is, if I loop the hashmap of testStatus to have different values in each loop and clean up at the end of the loop ... how can I create a freemarker to display the testhatus key value pair from each loop.
If I haven't cleared the hashmap of testStatus, I get the cumulative result. But if I cleared the hashmap of testStatus the freemarker doesn't display anything.
+3
source to share