Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Spring将元素从util:列表复制到另一个列表;s xml_Java_Spring - Fatal编程技术网

Java 如何使用Spring将元素从util:列表复制到另一个列表;s xml

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

我使用的是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="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>