使用util独立Bean 配置单例的集合bean,以供多个bean进行引用。(将属性放在外部,可供多个类应用,而不是一个具体的内部 相当于抽离代码)
<util:list id="out">
<ref bean="helloSet"></ref>
<ref bean="helloSet"></ref>
</util:list>
<bean id="person" class="hello.Person">
<property name="name"><value>大佬</value></property>
<property name="hello" ref="out"></property>
</bean>
通过p命名空间为bean的属性赋值,需要先导入p命名空间 ,相对传统的配置方式更加简洁:
<util:list id="out">
<ref bean="helloSet"></ref>
<ref bean="helloSet"></ref>
</util:list>
<bean id="person" class="hello.Person" p:name="Spring" p:hello-ref="out"></bean>
本文介绍如何使用Spring的util命名空间配置Bean集合,并通过p命名空间简化Bean属性赋值过程。示例展示了如何创建可复用的集合Bean,并应用于多个Bean中。
1420

被折叠的 条评论
为什么被折叠?



