Sunday, January 12, 2014

Spring Course: V17 Property Maps

lets say we have the following class

public class Jungle {
private Map<String, String> foods = new HashMap<String, String>();
public void setFoods(Map<String, String> foods) {
this.foods = foods;

as you can see setFoods takes Map<String,String> as input

in order to set this value we write:

<bean id="jungle"class="com.caveofprogramming.spring.test.Jungle">
<property name="foods">
<prop key="gorilla">banana</prop>
<prop key="panda">bamboo</prop>
<prop key="snake">eggs</prop>

as you can see we use <props> in order to set Map value.

No comments:

Post a Comment