title: Freemarker: iterating nested list in hash
body: <p>I want to iterate a List nested in a Map, the data structure is like: </p>
  
  <pre><code>Map&lt;Integer, List&lt;Integer&gt;&gt; groups = new TreeMap&lt;&gt;()
  // Some code else to put values into groups ...
  </code></pre>
  
  <p>Freemarker template:</p>
  
  <pre><code>&lt;#list groups?keys as groupKey&gt;
      ${groupKey}    // It's OK here.
      &lt;#list groups[groupKey] as item&gt;  // Exception threw here, detail message is pasted below
          ${item}
      &lt;/#list&gt;
  &lt;/#list&gt;
  </code></pre>
  
  <p>Detail exception message:</p>
  
  <blockquote>
    <p>FreeMarker template error:
    For "...[...]" left-hand operand: Expected a sequence or string or something automatically convertible to string (number, date or boolean), but this evaluated to an extended_hash (wrapper: f.t.SimpleHash):
    ==> groups</p>
  </blockquote>
  
  <p>So, what is the problem?</p>
  
  <p><strong>P.S.</strong></p>
  
  <p>I have tried <code>groups.get(groupKey)</code> instead of <code>groups[groupKey]</code>, it throws a new Exception stack:</p>
  
  <pre><code>java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
  java.lang.String.compareTo(String.java:108)
  java.util.TreeMap.getEntry(TreeMap.java:346)
  java.util.TreeMap.get(TreeMap.java:273)
  freemarker.template.SimpleHash.get(SimpleHash.java:160)
  freemarker.core.Dot._eval(Dot.java:40)
  freemarker.core.Expression.eval(Expression.java:76)
  </code></pre>