在bean的内部引用另一个bean对象:
使用ref标签对其进行引用: <ref bean="viewResolver2"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
<property name="order" value="2"/>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"/>
<!-- 引用外部id为viewResolver的bean -->
<ref bean="viewResolver"/>
</list>
</property>
</bean>
ref属性:用来给一个对象的属性设置值
使用<ref bean="viewResolver"/>
bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 在spring框架加载时创建 -->
<bean id="borrowDao" class="dao.impl.BorrowDao" primary="true" lazy-init="true">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
ref标签:用来引用另一个bean:
<ref bean="viewResolver"/>,在spring容器中群钊id为viewResolver的bean对象