title: How to access map key/value pair contained in a ModelMap object from jsp Spring MVC
body: <p>I have a ModelMap variable "model", the value object contained in the model map itself is a HashMap.</p>
  
  <p>Controller code:</p>
  
  <pre><code>public String func(ModelMap model) 
  {
      HashMap&lt;String, List&lt;String&gt; aMap = new HashMap&lt;String, List&lt;String&gt;();
      ArrayList&lt;String&gt; aList = new ArrayList&lt;String&gt;();
      ....// give aList some data
      aMap.put("keystring", aList);
      model.addAttribute("aMap", aMap); 
  
      String view = "test";
      return view;
  }
  </code></pre>
  
  <p>test.jsp code:</p>
  
  <pre><code> var data = '${aMap}'; 
   // I know this gets the entire aMap including its key ("keystring") 
   // and the value (aList)
   var key ='${aMap}.key'; 
   alert(key); 
   var value ='${aMap}.value'; 
   alert(value);  
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code> var va= data.key; // also tried data[key], data['key']
   alert(va);      
  </code></pre>
  
  <p>but they all printed either an empty string or undefined.  However, if I printed "data", then I can see the entire map.</p>
  
  <p>How do I access aMap's key ("keyString") and the value (aList) from test.jsp script part ?  Any help will be appreciated.</p>