Issue
I have a map in my properties file as below:
property1=Hello_1
property2=Hello_2
list={a:'A', b:'B', c:'C'}
and I have a model object that contains:
public class Model {
String s1;
String s2;
Map<String, String> map;
}
and I want to read it from applicationContext.xml and fill it in my java Map like below:
<bean id="model" class="Model">
<property name="s1" value="${property1}" />
<property name="s2" value="${property2}" />
<property name="map" value="${list}" />
</bean>
I can read s1
and s2
successfully and fill it in the model, but I don't know how to fill the map
collection, any idea?
Solution
You need to use Spring expression to handle that. Try <property name="map" value="#{${list}}" />
Answered By - Jun Jie
Answer Checked By - Terry (JavaFixing Volunteer)