1. Prerequisites
1) when the default scope is used for SSH integrated development, struts2 actions need to be managed using spring containers, as long as the classes involved are imported into spring containers in the form of beans, both xml configuration and annotation-based configuration involve spring's bean scope management. There are five values, and the default value is Singleton, which is the singleton model, all references to this bean are the same object.
2) the action should be a multi-sample struts2 framework of the view layer in MVC. Its main task is to receive user requests and then call the business logic layer for processing, this feature means that each HTTP request must correspond to a separate action. Otherwise, data conflicts may occur.
3) The problem arises. We can see from the above two points that the two are in conflict. Therefore, when spring needs to manage action, it must change its scope to prototype instead of using its default value-Singleton. 2. Error
When adding a user, if spring manages the action by default (Singleton, when the data is added again, it is found that the data is automatically displayed (only when the struts2 label is used and modeldriven is used). This applies to both the closed browser and other browsers. <s: debug> during tag calling, it is found that the top of the stack of the value Stack's root stack is the user (model) added previously ).
3. cause Analysis 1) when the spring container starts the spring container, it will create an instance for adding user action. Because its scope is in singleton mode, the same action object will be called every time this action is requested in the future, as a result, the seeds of extinction are also buried.
2) After the modeldriven interceptor user enters the information, click Submit. Because the user needs to encapsulate the input data in the form, the modeldriven interface is implemented using the most standard data encapsulation method. When an action is requested to be added, it passes through the modeldriven interceptor, the interceptor obtains the target model through the GetModel method and pushes it to the top of the valuestack stack;
2) When the param interceptor passes through the interceptor Params, it will assign a value to the model at the top of the stack.
3) execute action to add action to complete the subsequent operation.
4) request to add action again. At this time, the added action is retrieved from the spring container. Because its scope is Singleton, this action is the same as the previous action, previously added files are also saved in action.
5) the model in the action is placed on the top of the valuestack stack and the model contains a value.
6) when the interface arrives at the interface, the echo is performed according to the model value.
Default scope during SSH Integrated Development