spring的scope="prototype" java程序员

项目中对一个表的增删该操作是用一个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]

原文地址:https://www.cnblogs.com/java20130725/p/3215764.html