أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
in Spring bean configuration file inside the bean write one property tag
<bean>
<property list="">
<llist>
</list>
</bean>
in the spring bean we can autowired and by help of xml conf. file inject the list elements, dependency injection feature of spring need to use.
<Bean id="" >
<property value="" />
<list>
.........
</list>
</bean>
By Using Spring IOC Dependency Injection
<property ------->
<list -->
---------
</list>
</property>
Inside Spring configuraton file where we will use bean configuration inside bean tag.
<bean>
<list>
<value></value>
</list>
</bean>
xml configuration for injecting(DI) List into the spring bean.
ex - <util:list id="" value-type="java.lang.String"><value></value></util:list>
using spring dependency injection with property name of list
<PROPERTY NAME="list">
<LIST>
<VALUE>GVO</VALUE>
<VALUE>GVP</VALUE>
</LIST>
</PROPERTY>
TO INJECT LIST<STRING> INTO SPRING W HAV TO USE <LIST> TAG IN XML FILE WHIH IS SUB ELEMENT OF <PROPERTY> TAG AND <CONSTRUCTOR-ARG> TGA
SEE:
<PROPERTY NAME="A">
<LIST>
<VALUE>ANUJ SINGH</VALUE>
<VALUE>POOJA SINGH</VALUE>
</LIST>
</PROPERTY>
HERE PROPERTY NAME IS NAME OF LIST LIKE:LIST<STRING>A
NOW AT A[0]=ANUJ SINGH
A[1]=POOJA SINGH
list.of.strings=first,second,third took from properties file for e.g.
Then using SpEL:
@Value("#{'${list.of.strings}'.split(',')}")
private List<String> list;
In XML we can use <util:list id="myList" value-type="java.lang.String">
Add Collection dependency injection in the spring servlet.xml