the difference between value and ref in Spring?

R

rmn190

my before understanding of the that is:
by value,we mean that what we want inject is primitives or
String,while with ref,what we want to inject is self-difined objects.

but i find some different today when i reread the Spring
document(version is spring-framework-2.0.6),in the section of
"3.3.3.1.1. The idref element",there is an example to explain the
idref element,it is :

<bean id="theTargetBean" class="..."/> ---(1)
<bean id="client" class="...">
<property name="targetName">
<value>theTargetBean</value>
</property>
</bean>
</bean>

and

<bean id="theTargetBean" class="..."/> ---(2)
<bean id="client" class="...">
<property name="targetName">
<idref bean="theTargetBean" />
</property>
</bean>
</bean>,
and the docs says:
bean definition snippet (2) is exactly equivalent (at runtime) to
the snippet (1).

could you help with that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top