Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3453270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:21:17+00:00 2026-05-18T09:21:17+00:00

greetings all i am using velocity templates when sending emails and i want to

  • 0

greetings all
i am using velocity templates when sending emails
and i want to read texts dynamically from property files depending on user locale

the xml config:

<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>

and when trying to read the text from property file like :

<span>#springMessage("hi.message")</span>

it doesn’t read any thing, or prints the default value, just prints:

$springMacroRequestContext.getMessage($code)

i don’t know why? , am i missing something ?, any help ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:21:18+00:00Added an answer on May 18, 2026 at 9:21 am

    macros can’t be used outside web app like in email templates, so a solution would be to pass messageSource to the vm file and read from the property file by it like the answer in here:

    Is it possible to read static text dynamically from property files in velocity template?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings All; I am a beginner in using regex. What I want to do
greetings all i have a problem that when sending an email from the server
Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
Greetings to all... I want to use fade effect with jCarouselLite qualities. Is it
greetings all i am using the following method to get the current time in
Greetings all. I am writing some code using the Boost Units library and have
Greetings, I'm going to get exif info from some images using android. I know
greetings all i have a web application using (spring-hibernate) frameworks and when tried to
greetings all i am using jsp as a view technology in my web app
Greetings all i am using the following method to make programmatic login for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.