spring <bean scope="prototype">探讨
2009-05-18 15:27
627 查看
在配置spring applicationContext.xml中
<bean id="person" class="com.zcq.model.Person" scope="prototype"></bean>
<bean id="serviceImp" class="com.zcq.serviceImp.ServiceImp"></bean>
scope="prototype"没写的问题,项目中对一个表的增删该操作是用一个action,这个action有add,update,delete,save这些方法,
添加和修改是共用一个页面,当页面得到id时代表进行的修改操作,反之是添加操作。因为在配置spring的bean是忘了写scope="prototype"
所以每次添加时都显示最后一次访问过的记录,找了很长时间,原来是spring bean出了问题。 scope="prototype" 会在该类型的对象被请求
时创建一个新的action对象。如果没有配置scope=prototype则添加的时候不会新建一个action,他任然会保留上次访问的过记录的信息
这是我对protype配置的理解,不知道大家有什么更好的理解,有的话请留言
<bean id="person" class="com.zcq.model.Person" scope="prototype"></bean>
<bean id="serviceImp" class="com.zcq.serviceImp.ServiceImp"></bean>
scope="prototype"没写的问题,项目中对一个表的增删该操作是用一个action,这个action有add,update,delete,save这些方法,
添加和修改是共用一个页面,当页面得到id时代表进行的修改操作,反之是添加操作。因为在配置spring的bean是忘了写scope="prototype"
所以每次添加时都显示最后一次访问过的记录,找了很长时间,原来是spring bean出了问题。 scope="prototype" 会在该类型的对象被请求
时创建一个新的action对象。如果没有配置scope=prototype则添加的时候不会新建一个action,他任然会保留上次访问的过记录的信息
这是我对protype配置的理解,不知道大家有什么更好的理解,有的话请留言
相关文章推荐
- spring <bean scope="prototype">探讨
- Spring配置<bean>时加scope="prototype"的原因
- <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
- Spring中<ref local=""/>与<ref bean=""/>区别
- Spring中<ref local=""/>与<ref bean=""/>区别
- Spring中<ref local=""/>与<ref bean=""/>区别
- Spring中<ref local=""/>与<ref bean=""/>区别
- Spring中<ref local=""/>与<ref bean=""/>区别
- Spring中<ref local=""/>与<ref bean=""/>区别
- <bean id="ViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- spring bean scope="prototype" 有状态bean 无状态bean
- Spring中<ref local=""/>与<ref bean=""/>区别(转载)
- Spring中<ref local=""/>与<ref bean=""/>区别
- [Spring]<context:annotation-config/>注册的BeanPostProcessor
- Spring配置文件详解一:<context:annotation-config/>与<context:component-scan base-package="com.x
- spring bean scope=prototype/singleton的差别
- Spring3自定义环境配置 <beans profile="">
- spring 的scope="prototype"
- Spring注解@Scope("prototype")
- Spring基础_通过java代码装配bean<二>