Spring bean声明中的ref vs idref属性 [英] ref vs idref attributes in spring bean declaration

查看:151
本文介绍了Spring bean声明中的ref vs idref属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我两者之间的区别吗

Can someone tell me the difference between

<bean id="b1" class="" />

<bean id="" class="">
 <property name="b1" ref="b1" />
</bean>

<bean id="" class="">
 <property name="b1" idref="b1" />
</bean>

什么时候需要使用哪一个?

and which one has to be used when?

推荐答案

ref用于传递引用所引用的bean.
idref用于传递所引用的bean的名称(作为String).

ref is used to pass the bean that the ref refers to.
idref is used to pass the name of the bean (as a String) that is referred to.

http://forum.springsource.org/showthread.php?t=74355

这篇关于Spring bean声明中的ref vs idref属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆