1. 程式人生 > >property和constructor-arg的使用

property和constructor-arg的使用

注入集合屬性,使用list,map,set和props標籤,分別對應List,Map,Set和Properties:

<bean id="injectCollection" class="com.apress.prospring.ch4.CollectionInjection">

       <property name="map">

           <map>

               <entry key="someValue">

                   <value>Hello World!</value>

               </entry>

               <entry key="someBean">

                   <ref local="oracle"/>

                </entry>

           </map>

       </property>

       <property name="props">

           <props>

               <prop key="firstName">

                   Rob

               </prop>

               <prop key="secondName">

                   Harrop

               </prop>

           </props>

       </property>

       <property name="set">

           <set>

               <value>Hello World!</value>

               <ref local="oracle"/>

           </set>

       </property>

       <property name="list">

           <list>

               <value>Hello World!</value>

               <ref local="oracle"/>

            </list>

       </property>

   </bean>