問候所有 發送電子郵件 時,我想從屬性文件,這取決於用戶的語言環境無法使用電子郵件模板中的速度使用宏?
XML配置動態讀取文本,我使用Velocity模板:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:messages</value>
<value>classpath:messages_ar</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<props>
<prop key="resource.loader">class</prop>
<prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
<prop key="velocimacro.library">org/springframework/web/servlet/view/velocity/spring.vm</prop>
</props>
</property>
</bean>
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/classes/com/spacerdv/mailTemplates"/>
</bean>
<!--
View resolvers can also be configured with ResourceBundles or XML files. If you need
different view resolving based on Locale, you have to use the resource bundle resolver.
-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".vm"/>
<!-- if you want to use the Spring Velocity macros, set this property to true -->
<property name="exposeSpringMacroHelpers" value="true"/>
</bean>
當試圖從屬性文件中讀取文本,如:
<span>#springMessage("hi.message")</span>
它不讀任何東西,或打印的缺省值,只是打印:
$springMacroRequestContext.getMessage($code)
我不知道爲什麼? ,我錯過了什麼?,有什麼幫助?
我添加應用上述配置後,現在出現的值$ springMacroRequestContext.getMessage($ code),你怎麼看?我還有另一個問題,是在哪裏定義速度使用的屬性文件? – 2010-12-01 15:10:00