Announcement Announcement Module
Collapse
No announcement yet.
How to load values of a property as List Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to load values of a property as List

    Hi All,

    I have a property file and one of the propery can have multiple values. I am using PropertyPlaceholderConfigurer to load the propertied to a Java Bean.

    e.g (Property can have multiple values.)
    userids=1,2

    Currently the bean converts the property value to a List containing one object. i.e value of the first object is "1,2".

    Can we configure some way it to take it as two elements.

    Regards
    Nagaprakash

  • #2
    Hi,

    You can take advantage of fact that Spring allows to initialize value of type String[] by providing comma separated list of values. To do so, you have to explicitly specify type in <value> element in your bean definition file:
    Code:
    <bean class="YourBeanClass">
    	<property name="userIds">
    		<value type="java.lang.String[]">1,2,3</value>
    	</property>
    </bean>
    Of course, to retrieve actual user IDs from property file, replace literal "1,2,3" with placeholder "${userids}".

    Regards,
    Algirdas

    Comment

    Working...
    X