title: Struts 2 - Saving value in map inside a map
body: <p>I'm currently working with Struts 2 and I have this situation: </p>
  
  <p>In my Action class: </p>
  
  <pre class="lang-java prettyprint-override"><code>private Map&lt;String, Map&lt;Integer, MyEntity&gt;&gt; map; 
  
  public void setMap(Map&lt;String, Map&lt;Integer, MyEntity&gt;&gt; map) { 
        this.map = map; 
  } 
  
  public Map&lt;String, Map&lt;Integer, MyEntity&gt;&gt; getMap() { 
        return this.map; 
  } 
  </code></pre>
  
  <p>In my JSP, I use an iterator to go through the map using the 'key' variable, then iterate over another list (of integers) and use this integer to go through the second map, like this: <code>map[${key}][${myInteger}]</code></p>
  
  <pre class="lang-jsp prettyprint-override"><code>&#60;s:iterator value="map" status="status"&#62; 
    &#60;tr&#62; 
      &#60;td&#62;${status.index}&#60;/td&#62; 
      &#60;td&#62;${key}&#60;/td&#62; 
      &#60;s:iterator value="integersList" id="myInteger"&#62; 
        &#60;td&#62; 
          &#60;s:textfield name="map[${key}][${myInteger}].myEntityAttribute" value="%{map[#attr.key][#attr.myInteger].myEntityAttribute}" id="attr_${key}_${myInteger}" theme="simple" size="10" /&#62; 
        &#60;/td&#62; 
      &#60;/s:iterator&#62; 
    &#60;/tr&#62; 
  &#60;/s:iterator&#62;
  </code></pre>
  
  <p>Doing this for getting the value works fine: <code>value="%{map[#attr.key][#attr.myInteger].myEntityAttribute}"</code></p>
  
  <p>But when I want to save the changes I can not make it work: <code>name="map[${key}][${myInteger}].myEntityAttribute"</code></p>
  
  <p>I don't know what I am doing wrong, or if this can not be done (I'm pretty sure there must be a way), but I'm kind of tired of trying. </p>
  
  <p>I would appreciate any suggestions, really, anything that can help is welcomed. </p>