list - How to iterate over a property file in Spring xml -
i have property file details2.txt
, filled values :
list.value=34 list.value=35 list.value=38 list.value=45 list.value=23
now want iterate in spring xml , unable
xml code (parts only) : <context:property-placeholder location="details2.txt" /> <constructor-arg> <list> <value>${list.value}</value> </list> </constructor-arg>
this gives last value in property file
a property file translated properties
object, in turn subclass of hashtable
, contains one-to-one mapping key value. means properties object indeed contain last value (since previous ones have been overwritten).
one common way of handing problem in property files add suffix keys:
list.value.1=34 list.value.2=35 list.value.3=36 list.value.4=37
but doesn't when using spring, since each property key need explicitly specified in xml file (and i'm assuming don't know exact number of items).
your best bet specify items comma-separated list:
list.values=34,35,36,37
Comments
Post a Comment