使用Spring框架中添加速度文件夹中的类路径 [英] Adding folder to classpath in Velocity using Spring framework
问题描述
我如何添加整个文件夹速度和使用里面的文件作为资源包?
How can I add an entire folder to Velocity and use the files inside as resource bundles?
目前在我的velocity.xml我有这个code:
Currently in my velocity.xml I have this code:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="parentMessageSource">
<ref bean="globMessageSource"/>
</property>
<property name="basenames">
<list>
<value>classpath:/WEB-INF/i18n</value>
<value>/WEB-INF/templates/velocity/my_vm_template</value>
</list>
</bean>
我需要的i18n文件夹添加到类路径,使其包含文件可以在toolbox.xml的VelocityTools 1.4版本中可以看出:
I need to add i18n folder to the classpath so that its containing files can be seen by the VelocityTools version 1.4 in the toolbox.xml:
<tool>
<key>test</key>
<scope>request</scope>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="i18n.ss_messages"/>
<parameter name="locale" value="en_US"/>
</tool>
在code是给我的错误信息:java.util.MissingResourceException:找不到捆绑为基本名称i18n.ss_messages,地方en_US
The code is giving me an error message: "java.util.MissingResourceException: Can't find bundle for base name i18n.ss_messages, locale en_US"
这个问题涉及到<一个href=\"http://stackoverflow.com/questions/8221161/velocitytools-error-java-util-missingresourceexception-cant-find-bundle-for\">VelocityTools错误 - &QUOT; java.util.MissingResourceException:无法找到捆绑的基本名称WEB-INF.conf.resources.ss_messages,地方en_US&QUOT;
很抱歉,如果这是一个愚蠢的问题,但我找不到任何位置描述如何将整个文件夹添加到类路径,并可以作为一个包,因此它可以支持Velocity模板的本地化。
Sorry if it's a silly question, but I can't find anywhere describing how to add an entire folder to the classpath and be available as a bundle so it can support Velocity template localization.
重要提示!如果我把我的ss_messages_bg_BG.properties和ss_messages_en_US.properties文件/ WEB-INF /班/ i18n的话它的工作原理,但我想将它们放在不同的文件夹最好在/ WEB-INF /模板/ i18n的。我该怎么做呢?
IMPORTANT NOTE!! If I place my ss_messages_bg_BG.properties and ss_messages_en_US.properties files in /WEB-INF/classes/i18n then it works, but I want to place them in a different folder ideally in /WEB-INF/templates/i18n. How do I do that?
推荐答案
你用maven?你可以告诉Maven来使用该目录作为一种资源:
Do you use maven? You could tell maven to use that directory as a resource:
<resource>
<!-- Velocity requires to be in classpath -->
<directory>src/main/webapp/WEB-INF/i8n</directory>
<filtering>true</filtering>
</resource>
这篇关于使用Spring框架中添加速度文件夹中的类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!