(scope="prototype")解除“页面提交后保留上次访问过的记录信息”
2010-09-11 21:12
323 查看
下面是struts2+hibernate+spring配置文件的一部分,以前都是仿造已经写好的bean的配置。有一次 scope="prototype"忘记写了结果出了问题
项目中对一个表的增删该操作是用一个action,这个action有add,update,delete,save这些方法,添加和修改是共用一个页面,当页面得到id时代表进行的修改操作,反之是添加操作。因为在配置spring的bean是忘了写scope="prototype"所以每次添加时都显示最后一次访问过的记录
找了很长时间,原来是spring bean出了问题。 scope="prototype" 会在该类型的对象被请求时创建一个新的action对象。如果没有配置scope=prototype则添加的时候不会新建一个action,他任然会保留上次访问过的记录信息。
<bean id="assetAction" class="com.servicezone.itsd.asset.webapp.action.AssetAction" scope="prototype">
<property name="assetManager" ref="assetManager"/>
<property name="itProductManager" ref="itProductManager"/>
<property name="vendorManager" ref="vendorManager"/>
<property name="deptManager" ref="deptManager"/>
<property name="userManager" ref="userManager"/>
<property name="assetTypeManager" ref="assetTypeManager"/>
</bean>[/size][/size][/size][size=medium][/size]
几个用户并发操作的时候会出现问题的!变量什么的会共用到的。。。所以scope要设成prototype或者request
项目中对一个表的增删该操作是用一个action,这个action有add,update,delete,save这些方法,添加和修改是共用一个页面,当页面得到id时代表进行的修改操作,反之是添加操作。因为在配置spring的bean是忘了写scope="prototype"所以每次添加时都显示最后一次访问过的记录
找了很长时间,原来是spring bean出了问题。 scope="prototype" 会在该类型的对象被请求时创建一个新的action对象。如果没有配置scope=prototype则添加的时候不会新建一个action,他任然会保留上次访问过的记录信息。
<bean id="assetAction" class="com.servicezone.itsd.asset.webapp.action.AssetAction" scope="prototype">
<property name="assetManager" ref="assetManager"/>
<property name="itProductManager" ref="itProductManager"/>
<property name="vendorManager" ref="vendorManager"/>
<property name="deptManager" ref="deptManager"/>
<property name="userManager" ref="userManager"/>
<property name="assetTypeManager" ref="assetTypeManager"/>
</bean>[/size][/size][/size][size=medium][/size]
几个用户并发操作的时候会出现问题的!变量什么的会共用到的。。。所以scope要设成prototype或者request
相关文章推荐
- 页面每次添加都显示最后一次访问记录spring scope="prototype" 学习笔记
- Sping scope="prototype"属性和Struts保留关键字,揭秘难以找到原因的错误
- scope:"singleton"与"prototype"学习记录
- spring scope="prototype" 和scope="singleton"区分
- spring&nbsp;scope=&quot;prototype&quot;&amp;nb…
- CentOS提示"另一个目前运行的程序正在访问软件信息"
- struts+spring action应配置为scope="prototype"
- spring scope="prototype" 和scope="singleton"区分
- "增加记录"时防止重复提交
- 提交一个from的时候,struts2处理完返回结果打开一个新页面,用target="blank"
- Spring的scope="prototype"属性
- 解除SQL对组件"Ad Hoc Distributed Queries"的"STATEMENT'OpenRowset OpenDatasource"的访问
- spring scope="prototype" 和scope="singleton"区分
- sping+struts2中配置Action的bean中scope="prototype"的作用
- F5当刷新页面,出现“要再次显示此页,web该浏览器,你曾经有过发送消息再次提交...点击重试",如何防止此对话框解决方案的出现,
- Spring中scope="prototype"属性的作用
- 关于Spring的destroy-method和scope="prototype"不能共存问题
- 部署错误:尚未授予访问 Tomcat 服务器的权限。请在服务器管理器的 Tomcat 定制器中设置 "manager-script" 角色的正确用户名和口令。 有关详细信息,请查看服务器日志。
- Spring注解@Scope("prototype")
- SharePoint 2013 页面访问,Url中间多一段&quot;_layouts/15/start.aspx#&quot;