spring: a bean that receives a list of Classes
I want to define in my Spring XML conte开发者_C百科xt a bean that has a property of the type List of classes: i.e. List<Class<?>> classes
How do I send that bean a number of classes, say java.lang.String and java.lang.Integer?
The list needs not be reusable, i.e. I will not refer to it in another bean.
With Spring, the simplest possibility usually works.....
<property name="classes">
<list>
<value>java.lang.String</value>
<value>java.lang.Integer</value>
</list>
</property>
<property name="classes">
<list>
<bean class="java.lang.Class" factory-method="forName">
<constructor-arg value="java.lang.String"/>
</bean>
</list>
</property>
Something like that...
精彩评论