<bean> 中配置详解 </bean>

<bean> ***</bean>

这叫做Spring的依赖注入也叫控制反转。bean的id也就是你说的bean的id,通过id找你想要调用的bean

<bean id="demo1Action" class="location1 of demo1"> ***</bean>

<bean id="demo2Action" class="location2 of demo2"> ***</bean>

1、property 属性:<property name=" user"  value="123">  user 你就可以在你的demo2Action中用它了

2、<property name="demo2Action"  ref="demo2Action">

ref不是一个单纯的值,ref那个位置如果你要传字符串那就可以用value代替,如果不是则ref则把你的id为demo2Action的一个bean传过去了,你在demo1Action中就可以使用id为demo2Action对象中的属性了,也就相当于你把demo2Action这个bean对象,在你的demo1Action中new出来了。

原文地址:https://www.cnblogs.com/hoojjack/p/6270984.html