Announcement Announcement Module
Collapse
No announcement yet.
Using MessageSource to get properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using MessageSource to get properties

    If I have a properties file in the following format:

    test1.properties
    test_var_1=10
    test_var_2=20

    Can't MessageSource be used to retrieve the values?

    <code>
    <bean id="testSource"
    class="org.springframework.context.support.Resourc eBundleMessageSource">
    <property name="basename" value="test1"></property>
    </bean>


    MessageSource messageSource = (MessageSource) getBean("testSource") ;
    return messageSource.getMessage(test1, null, null) ;
    </code>

  • #2
    And what is it you want to get? There is no property test1 in those files...

    Comment


    • #3
      should have been test_var_1. I see all of these PropertyConfig methods of getting a property and was just curious why didn't use MessageSource.

      Comment


      • #4
        Well if it is the name of a user or a password you don't want to use a MessageSource to retrieve those. Messages are in general dynamic in nature and properties are more or less static. Next to that you probably aren't going to need multilanguage for properties (I suspect the username for the english version of the website is the same as the dutch version).

        Comment

        Working...
        X