我在我的应用程序中使用 Struts2。我有一个 MessageResources.properties,其中给出了所有键和值。该文件位于 ${tomcat_home}/properties/resources
位置。我的问题是如何在 struts.xml
中提供此文件位置?在 struts.xml
中,我尝试给出
<constant name="struts.custom.i18n.resources" value="/usr/local/tomcat/properties/resources/MessageResources"/>
但这不起作用。未检索属性。
最佳答案
Struts2 从类路径加载属性。将属性文件放入给定包下的 src
或 resources
文件夹中。
如果包名称是com.example.resources
那么你应该使用
<constant name="struts.custom.i18n.resources" value="/com/example/resources/MessageResources"/>
关于java - Struts2 中的属性文件位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37570985/