Struts 2 bean配置默认范围 [英] Struts 2 bean configuration default scope
问题描述
我正在尝试使用配置文件使用Struts2的基本DI,如这里所述。
I'm trying to use basic DI with Struts2 using the configuration file as described here.
但是,我无法找到注入bean的默认范围。
However, I was not able to find what the default scope is for injecting a bean.
我知道Spring的默认范围是Singleton,但我不想假设与Struts2相同。
I know that the default scope is Singleton for Spring but I didn't want to assume the same with Struts2.
任何想法?
推荐答案
默认范围是 singleton
,但是有一个名称为的范围默认
哪个不同。可以通过这个问题让您更好地了解Struts2中的范围。框架支持范围,如 singleton
,默认
和线程
你应该手动实现的其他范围。
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.
澄清名为的范围,默认
表示每次注入一个实例。您可以在评论中找到 Scope.DEFAULT 。
To clarify the scope named default
means a one instance per injection. You can find this in comments to Scope.DEFAULT.
这篇关于Struts 2 bean配置默认范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!