0

In Spring's configuration xml with SpEL we can populate the list in this way:

<util:list id="cities">
<bean class="com.habuma.spel.cities.City"
p:name="Chicago" p:state="IL" p:population="2853114"/>
<bean class="com.habuma.spel.cities.City"
p:name="Atlanta" p:state="GA" p:population="537958"/>
<bean class="com.habuma.spel.cities.City"
p:name="Dallas" p:state="TX" p:population="1279910"/>
<bean class="com.habuma.spel.cities.City"
p:name="Houston" p:state="TX" p:population="2242193"/>
<bean class="com.habuma.spel.cities.City"
p:name="Odessa" p:state="TX" p:population="90943"/>
<bean class="com.habuma.spel.cities.City"
p:name="El Paso" p:state="TX" p:population="613190"/>
<bean class="com.habuma.spel.cities.City"
p:name="Jal" p:state="NM" p:population="1996"/>
<bean class="com.habuma.spel.cities.City"
p:name="Las Cruces" p:state="NM" p:population="91865"/>
</util:list>

how we can populate util:properties by Strings??

<util:properties id="some">

....

</util:properties>
Vikdor
  • 23,934
  • 10
  • 61
  • 84
alemale
  • 87
  • 1
  • 8

1 Answers1

0

You can use the props element, like this:

<props>
    <prop key="key1">value1</prop>
    <prop key="key2">value2</prop>
    ...
</props>

But that is not SpEL, as @M. Deinum already pointed out.

EDIT: incorporating some of the comments in the answer:

<util:properties> loads a Properties instance from the resource location specified by the "location" attribute, something like <util:properties id="some" location="myfile.properties" />. The following post shows how to read the location from a system property: how to read System environment variable in Spring applicationContext

Community
  • 1
  • 1
Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • loads a Properties instance from the resource location specified by the "location" attribute, something like – Bogdan Jan 06 '15 at 10:55
  • but what if i want read systemProperty -DAPP.LOG_PATH=/Users/wsaryada/tmp into util:properties ? – alemale Jan 06 '15 at 10:56
  • you mean something like in this post: http://stackoverflow.com/questions/3965446/how-to-read-system-environment-variable-in-spring-applicationcontext. See the response from "amra". – Bogdan Jan 06 '15 at 10:59