Java 如何使用Spring将元素从util:列表复制到另一个列表;s xml
我使用的是Spring 2.5,其想法如下:Java 如何使用Spring将元素从util:列表复制到另一个列表;s xml,java,spring,Java,Spring,我使用的是Spring 2.5,其想法如下: <util:list id="europe" > <ref bean="France" /> <ref bean="England" /> <ref bean="Spain" /> </util:list> <util:list id="america" > <ref bean="Mexico" /> <ref bean
<util:list id="europe" >
<ref bean="France" />
<ref bean="England" />
<ref bean="Spain" />
</util:list>
<util:list id="america" >
<ref bean="Mexico" />
<ref bean="Brazil" />
<ref bean="USA" />
</util:list>
<util:list id="world" >
<!-- copy elements from list "europe" -->
<!-- copy elements from list "america" -->
</util:list>
有可能吗?我认为这不是现成的支持 对于Spring2.5,您可以执行以下操作
<bean id="tmpList" class="org.apache.commons.collections.ListUtils"
factory-method="union">
<constructor-arg ref="europe" />
<constructor-arg ref="america" />
</bean>
<bean id="world" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList" ref="tmpList" />
</bean>
从3.0开始(使用Spel)
这在
util
命名空间中是不可能的。
<bean id="world" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList"
value="#{ T(org.apache.commons.collections.ListUtils).union(@europe, @america) }" />
</bean>