spring中ref属性与ref标签
在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="hibernate3.LocalSessionFactoryBean"> <!-- 在spring框架加载时创建 --> <bean id="borrowDao" class="dao.impl.BorrowDao" primary="true" lazy-init="true">
<property name="sessionFactory" ref="sessionFactory"></property>spring framework是什么框架的
</bean>
ref标签:⽤来引⽤另⼀个bean:
<ref bean="viewResolver"/>,在spring容器中钊id为viewResolver的bean对象
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论