应用程序运行时(内存或磁盘)存储消息包的位置在哪里?

时间:2012-09-18 10:19:58

标签: java struts2 struts

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

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分: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将使每个查找的physcial属性文件加载框架。