title: Spring MVC, HashMap as model - how to get value using javascript variable as key in jsp
body: <p>I have a model like this:</p>
  
  <pre><code> @ModelAttribute("availableFonts")
      public Map&lt;String, String&gt; getAllAvaliableFonts() {
       ...  
      }
  </code></pre>
  
  <p>Model is containing font name as a key and css code as a value. Now in jsp I have a javaScript code which should apply css dynamicly to preview font, which looks more/less like this:</p>
  
  <pre><code>var css = '${availableFonts.get("Arial Black")}';
  jQuery('#preview').removeClass().addClass(css);
  </code></pre>
  
  <p>And it's working good with hardcoded map.get(). Css value is taken from HashMap which is model in my jsp.</p>
  
  <p>But I need this map key as a javaScript variable like:</p>
  
  <pre><code> var key = 'Arial Black';
   var css = '${availableFonts.get("' + key + '")}';
   jQuery('#preview' + i).removeClass().addClass(css);
  </code></pre>
  
  <p>And it's not working. Is it possible to do it in javaScript ?</p>