Apache 使用Spring框架向Velocity中的类路径添加文件夹
如何将整个文件夹添加到Velocity并将其中的文件用作资源包 目前在my velocity.xml中,我有以下代码:Apache 使用Spring框架向Velocity中的类路径添加文件夹,apache,spring,internationalization,velocity,Apache,Spring,Internationalization,Velocity,如何将整个文件夹添加到Velocity并将其中的文件用作资源包 目前在my velocity.xml中,我有以下代码: <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="parentMessageSource"> <ref bean="globMess
<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>
类路径:/WEB-INF/i18n
/WEB-INF/templates/velocity/my_vm_模板
我需要将i18n文件夹添加到类路径中,以便toolbox.xml中的VelocityTools版本1.4可以看到其包含的文件:
<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>
测验
要求
org.apache.velocity.tools.generic.ResourceTool
代码给了我一条错误消息:“java.util.MissingResourceException:找不到基本名称i18n.ss_消息的捆绑包,locale en_US”
这个问题涉及到
如果这是一个愚蠢的问题,很抱歉,但是我找不到任何地方描述如何将整个文件夹添加到类路径并作为捆绑包提供,以便它能够支持Velocity模板本地化
重要提示如果我将我的ss_messages_bg_bg.properties和ss_messages_en_US.properties文件放在/WEB-INF/classes/i18n中,那么它可以工作,但我希望将它们放在另一个文件夹中,最好是放在/WEB-INF/templates/i18n中。我该怎么做呢?你使用maven吗?您可以告诉maven将该目录用作资源:
<resource>
<!-- Velocity requires to be in classpath -->
<directory>src/main/webapp/WEB-INF/i8n</directory>
<filtering>true</filtering>
</resource>
src/main/webapp/WEB-INF/i8n
符合事实的