我有一个像这样的属性文件:

firstproperty=1,2,3,4
secondproperty=47,998,120
thirdproperty=54


我的属性文件在Spring配置中定义为PropertyPlaceHolderConfigurer bean的属性。

我想加载一个值

HashMap<String, ArrayList<String>>


像这样 :

<util:map id="properties" map-class="java.util.HashMap">
    <entry key="first" value="${firstproperty}" />
    <entry key="second" value="${secondproperty}" />
    <entry key="three" value="${thirdproperty}" />
</util:map>


问题在于,对于每个条目,用逗号分隔的多个值将作为一个值。我尝试将util-map的value-type配置为ArrayList,但未成功。任何的想法 ?

附言:我使用Spring 3.2。

最佳答案

我在配置文件中搜索了Spring EL,也许这就是您想要的:

<bean id="taxCalculator" class="org.spring.samples.TaxCalculator">
<property name="defaultLocale" value="#{ systemProperties['user.region'] }.split(',')"/>

<!-- other properties -->




我不确定split方法的位置,可以尝试找到正确的方法。有关更多详细信息,请参阅:http://docs.spring.io/spring/docs/3.0.x/reference/expressions.html

10-07 19:52
查看更多