Struts 2 bean configuration default scope

2019-05-26 16:27发布

问题:

I'm trying to use basic DI with Struts2 using the configuration file as described here.

However, I was not able to find what the default scope is for injecting a bean.

I know that the default scope is Singleton for Spring but I didn't want to assume the same with Struts2.

Any ideas?

回答1:

The default scope is singleton, but there's a scope with name default which is different. May be this question let you better understand scopes in Struts2. The framework support scopes like singleton, default, and thread other scopes you should implement manually.

Look at the source code where the scopes are defined.

To clarify the scope named default means a one instance per injection. You can find this in comments to Scope.DEFAULT.