EL map lookup using string key containing single quote
<p>I have a Java <code>HashMap&lt;String,String&gt;</code> that is being provided to a JSP page (<code>itemTypesByKey</code>) via a <code>ModelAndView</code> from Spring, and a separate structure containing a list of keys. (These keys may or may not result in a valid lookup.) I enumerate over these keys, and snag values from the map.</p>

<pre><code>Map&lt;String, String&gt; itemTypes = new HashMap&lt;&gt;();
itemTypes.put("NormalValue", "INGREDIENT");
itemTypes.put("Apostro'Value", "INGREDIENT");
ModelAndView mav = ...
mav.addObject("itemTypesByKey", itemTypes);
</code></pre>

<p><em>The problem</em> I'm seeing, is that if my key contains an apostrophe, the lookup fails.</p>

<p>My code (for debugging purposes):</p>

<pre><code>Key Name: ${currentKeyName}
Not Empty: ${not empty itemTypesByKey[currentKeyName]}
Type: ${itemTypesByKey[currentKeyName]}
All Suite Types: ${itemTypesByKey}
</code></pre>

<p>Ends up printing, for two separate keys:</p>

<pre><code>Key Name: NormalValue
Not Empty: true
Type: INGREDIENT
All Suite Types: {NormalValue=INGREDIENT, Apostro'Value=INGREDIENT}

Key Name: Apostro'Value
Not Empty: false
Type:
All Suite Types: {NormalValue=INGREDIENT, Apostro'Value=INGREDIENT}
</code></pre>

<p>I understand escaping apostrophe <em>literals</em> when they're used to lookup a value, but why does this fail if my key <em>contains</em> an apostrophe? How can I safely perform a lookup in my map regardless of whether the value of my key contains special characters?</p>

<p><strong>Edit:</strong> I'm using Spring version 3.1.4 (mvc, expression, etc.), and this issue does not affect keys containing exclamation points, or other special characters I could think to test.</p>