Single and multi-instance actions in SSH, SSHAction
The Bean in Structs2 is a singleton by default. During the entire program running, each Bean has only one instance. As long as the program is running, this instance will always exist.
For an Action, a singleton is prone to problems. If the parameters submitted by the client are the same each time and the values submitted later overwrite the values submitted earlier, the problem is not very serious. However, if an optional parameter exists, for example, parameter 1 is submitted last time and parameter 2 is submitted next time. However, because it is a Singleton, the value of parameter 1 is not null at this time, it is still the value submitted last time. In this way, problems may occur easily.
The solution is to set the Action to multiple instances. An Action instance is generated for each request, so that the parameter values submitted multiple times will not affect each other. After the processing is completed, the Action instance will be automatically recycled. Compared with a single instance, multiple instances may occupy more memory, but no bug occurs.
Set Bean as a singleton:
<Bean id = "XXXAction" class = "com. XXX. action. XXXAction" scope = "singleton">
Set Bean to multiple examples:
<Bean id = "XXXAction" class = "com. XXX. action. XXXAction" scope = "prototype">