title: Freemarker Hashtable<Integer, String>, iterate by keys
body: <p>I have a number of hashtables with Integers as keys, and i want to be able to iterate over them in my Freemarker templates, however, nothing seems to work. </p>
  
  <p>I tried the example from <a href="https://stackoverflow.com/questions/1497777/freemarker-iterating-over-hash-map-keys">Freemarker iterating over hashmap keys</a>:</p>
  
  <pre><code>
  &lt;#list user.props() as prop>
     ${prop} = ${user.get(prop)}
  &lt;/#list>
  </code></pre>
  
  <p>It probably works with Strings as keys, but it didn't with Integers. I also can't even retrieve the value from my hashtable by the concrete value. What i have is:</p>
  
  <pre><code>Hashtalbe ht = new Hashtable();
  ht.put(1, "hello");
  datamodel.put("devices", ht);</code></pre>
  
  <p>(datamodel being the hashmap passed to the template).</p>
  
  <p>In the template i do the following: </p>
  
  <pre><code>
  &lt;#if devices??>
   &lt;#list devices?keys as prop>
    &lt;p>${prop}&lt;/p>
    &lt;p>${devices.get(1)}&lt;/p>
  <hr>
  OR
  <hr>
    &lt;p>${devices.get(key)}&lt;/p>
  <hr>
  OR
  <hr>
    &lt;p>${devices[key]}&lt;/p>
  <hr>
  OR
  <hr>
    &lt;p>${devices[1]}&lt;/p>
   &lt;/#list>
  &lt;#else>
   &lt;p> no devices&lt;/p>
  &lt;/#if>
  </code></pre>
  
  <p>But none of that works. Can you help me, please?</p>
  
  <p>PS. I converted the hashtable from  into  to pass it to the template, but that seems like a bit of a workaround.</p>
  
  <p>Best regards, 
  Timofey</p>