繁体   English   中英

Spring PropertyPlaceholderConfigurer和具有多个值的键

[英]Spring PropertyPlaceholderConfigurer and keys with multiple values

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

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,但未成功。 任何想法 ?

PS:我使用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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM