The scope property of the bean is Prototype,singleton,request, and several properties of the session
When spring and struts2 are integrated, the STRUTS2 action is configured to scope= "prototype", which is for thread safety,
The following is part of the struts2+hibernate+spring configuration file, which used to mimic the configuration of a well-written bean. Once Scope= "prototype" forgot to write the result of the problem, its default is scope= "Singleton", the only.
Additions to a table in the project the action is to use an action, the action has add,update,delete,save these methods, add and modify is to share a page, when the page gets the ID of the modification operation, and vice versa is the add operation. Because the bean in the configuration spring is forgetting to write scope= "prototype", the last visited record is displayed each time it is added.
For a long time, it turned out that the spring Bean was out of the question. Scope= "prototype" creates a new action object when the object of that type is requested. If you do not configure scope=prototype, you will not create a new action when you add it, and he will leave the last logged-on information.
<bean id= "assetaction" class= "Com.servicezone.itsd.asset.webapp.action.AssetAction" scope= "prototype">
Since the action is configured with scope= "prototype", the bean in action cannot be configured as scope= "Request, otherwise it will be an error: org.springframework.beans.factory.beancreationexcepti On:error creating bean with Name ' customer ': Scope ' request ' isn't active for the current thread; Consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; Nested exception is Java.lang.IllegalStateException:No thread-bound request Found:are your referring to request attribute s outside of an actual Web request, or processing a request outside of the originally receiving thread? If you be actually operating within a Web request and still receive this message, your code is probably running outside O F Dispatcherservlet/dispatcherportlet:in This case, use Requestcontextlistener or requestcontextfilter to expose the Curr ENT request.
It's also understandable that action is new every time, but the property inside is not
The scope property of the bean in spring is understood