问题描述
我试图整合VelocityTools.ResourceTool本地化速度模板,但不管我的'捆绑'参数使用我不断收到以下错误:
I'm trying to integrate VelocityTools.ResourceTool to localize velocity template but whatever I use as the 'bundles' parameter I keep getting the following error:
java.util.MissingResourceException: Can't find bundle for base name
WEB-INF.conf.resources.ss_messages, locale en_US
我使用VelocityTools V1.4。这里是我的配置:
I'm using VelocityTools v1.4. Here are my configurations:
工具配置 /WEB-INF/conf/misc/velocity/toolbox.xml
<tool>
<key>test</key>
<scope>request</scope>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="WEB-INF.conf.resources.ss_messages"/>
<parameter name="locale" value="en_US"/>
</tool>
软件包:
\WEB-INF\conf\resources\ss_messages_bg_BG.properties
\WEB-INF\conf\resources\ss_messages_en_US.properties
这两个文件有简单的内容:
The two files have simple content:
full.name=\u0421\u0442\ (for bg_BG.properties)
full.name=Joe Blow (for en_US.properties)
我的Velocity模板有这个code:
My Velocity template has this code:
HELLO $test.full.name
我试过的不同值名称=以上,即捆绑
, / WEB-INF / conf目录/资源/ ss_messages
和 ./的conf /资源/ ss_messages
(去根目录,然后引用ss_messages束)。
I tried different values for the name="bundles"
above i.e., /WEB-INF/conf/resources/ss_messages
and ./conf/resources/ss_messages
(going to the root dir and then referencing the ss_messages bundle).
另外,我试图把我的ss_messages.properties包文件在资源
文件夹的根,并使用值=资源
来代替,但似乎没有正常工作...仍然得到同样的错误消息。
Also, I tried putting my ss_messages.properties bundle files in a resources
folder in the root and use the value="resources"
instead, but nothing seems to be working...still getting the same error message.
我在做什么错了?难道在 toolbox.xml
文件不在根?我一直在使用的成功 toolbox.xml
在我的应用程序到现在为止。
What am I doing wrong?! Is it that the toolbox.xml
file is not in the root? I've been using successfully the toolbox.xml
throughout my application up until now.
推荐答案
的资源应当在类路径中,并配置为这样。
The resources should be on the classpath, and configured as such.
查看 ResourceTool
API文档。
See the ResourceTool
API docs.
这篇关于VelocityTools错误 - &QUOT; java.util.MissingResourceException:无法找到捆绑的基本名称WEB-INF.conf.resources.ss_messages,地方en_US&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!