Reputation: 43
I have a map declaration:
<!-- SOME MAP -->
<util:map id="someMap" map-class="java.util.HashMap"
key-type="java.lang.String" value-type="java.lang.String" >
<entry key="0" value="SOME VALUE" />
<entry key="1" value="SOME VALUE 2" />
<entry key="default" value="SOME VALUE 3" />
</util:map>
<!-- SOME MAP REFERENCE -->
<util:map id="someMapRef" map-class="java.util.HashMap"
key-type="java.lang.String" value-type="java.util.HashMap" >
<entry key="0" value ref = "someMap" />
<entry key="default" value="SOME VALUE" />
</util:map>
What is wrong with that? Any suggestion?
Upvotes: 4
Views: 12832
Reputation: 298938
I think it should work like this:
<util:map
id="someMap"
map-class="java.util.HashMap"
key-type="java.lang.String"
value-type="java.lang.String">
<entry
key="0"
value="SOME VALUE" />
<entry
key="1"
value="SOME VALUE 2" />
<entry
key="default"
value="SOME VALUE 3" />
</util:map>
<!-- type: Map<String, Map<String, String>> -->
<util:map
id="someMapRef"
map-class="java.util.HashMap"
key-type="java.lang.String"
value-type="java.util.Map">
<entry
key="0"
value-ref="someMap" /> <!-- value-ref not "value ref" -->
<!-- This is the map constructed above -->
<entry
key="SOME_VALUE">
<map> <!-- and here is another map -->
<entry
key="SOME_OTHER_KEY1"
value="SOME_OTHER_VALUE1" />
<entry
key="SOME_OTHER_KEY2"
value="SOME_OTHER_VALUE2" />
<entry
key="SOME_OTHER_KEY3"
value="SOME_OTHER_VALUE3" />
</map>
</entry>
</util:map>
Upvotes: 0
Reputation: 403501
Firstly, the XML is not well-formed, it should be:
<entry key="0" value-ref="someMap"/>
Also, according to your definition, the someMapRef
map bean can only contain values of type java.util.HashMap
, but you're trying to set a value for key 0
of SOME VALUE
, which is a String. It can contain Strings, or hashMaps, but not both.
Upvotes: 9
Reputation: 14227
Not valid XML:
<entry key="0" value ref = "someMap" />
remove "value"
Upvotes: 0