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 5940703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:00:20+00:00 2026-05-22T16:00:20+00:00

<bean id=messageSource class=org.springframework.context.support.ResourceBundleMessageSource p:basename=messages /> bean and obviously in my velocity files I can

  • 0
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
        p:basename="messages" />

bean and obviously in my velocity files I can use #springMessage() to get needed message. But what if I want to get that message in my *.java controller? Is there some annotation that I can use like ?

@Annotation('message')
private String message;

Or I need to do it in different way?

Thanks

  • 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-22T16:00:21+00:00Added an answer on May 22, 2026 at 4:00 pm

    As long as you don’t need any internationalization, then you can use the messages.properties file with a PropertyPlaceHolderConfigurer (see the docs), along with the @Value annotation

    In XML:

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations" value="classpath:messages.properties"/>
    </bean>
    

    And in Java:

    @Value('message')
    private String message;
    

    You’ll also need <context:annotation-config/> to make this work (see docs)

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

Sidebar

Related Questions

In my application I already use ResourceBundleMessageSource <bean id=messageSource class=org.springframework.context.support.ResourceBundleMessageSource p:basename=i18n/messages /> And all
In my spring-servlet.xml I have <bean id=messageSource class=org.springframework.context.support.ReloadableResourceBundleMessageSource> <property name=basename value=/WEB-INF/messages /> </bean> My
I don't get this, I have a typical messageSource <bean id=resource class=org.springframework.context.support.ResourceBundleMessageSource> <property name=basenames>
applicationContext-Service.xml <bean id=messageSource class=org.springframework.context.support.ReloadableResourceBundleMessageSource> <property name=basenames> <list><value>messages</value></list> </property> </bean> I have messages_en_US.properties under /src/messages_en_US.properties
I read a bean code under spring-app.xml <bean id=mySessionFactory class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean> <property name=dataSource ref=myDataSource />
org.springframework.context.NoSuchMessageException: No message found under code 'user.username.empty' for locale 'en_GB'. Currently I have the
I have a DWR bean class which i can reference through JavaScript. I also
This is my UserDAO bean defined in spring context public class UserDAO{ public boolean
Can I access spring bean that exposed using http invoker (server) from GWT application
i have an managed bean(session scope) like this: class Home {// as homeBean public

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.