1

我正在使用 JAVA Struts2。我正在使用 ActionSupport 的 getText() (由 struts2 提供)读取属性文件。

4

2 回答 2

2

它们作为实例存储在 XWork 核心库 java.util.ResourceBundle中的静态ConcurrentMap中。LocalizedTextUtil

默认情况下,ResourceBundles 缓存在内存中。

于 2012-09-18T14:37:04.550 回答
2

默认情况下,它存储在内存中。但是,如果您想让框架为每次查找检查您的属性文件,您可以这样做。这对发展来说是一件好事。

您可以在struts.properties文件中配置此类内容。以下来自struts-default.properties,作为此类配置的注释样板。

### when set to true, Struts will act much more friendly for developers. This
### includes:
### - struts.i18n.reload = true
### - struts.configuration.xml.reload = true
### - raising various debug or ignorable problems to errors
###   For example: normally a request to foo.action?someUnknownField=true should
###                be ignored (given that any value can come from the web and it
###                should not be trusted). However, during development, it may be
###                useful to know when these errors are happening and be told of
###                them right away.
struts.devMode = false

### when set to true, resource bundles will be reloaded on _every_ request.
### this is good during development, but should never be used in production
struts.i18n.reload=false

true在您的文件中设置这两个属性中的任何一个WEB-INF/classes/struts.properties都会使框架从物理属性文件中加载以进行每次查找。

于 2012-10-18T19:16:31.720 回答