I wish to know if there is a way of passing a parameter conditionally while defining a spring bean. More specifically, I am trying to create a util:map with two entries, the entries are dependent on system properties as defined below:
<util:map id="queryParameterMap">
<entry key="star开发者_如何学PythontDate" value="${startdate}"/>
<entry key="endDate" value="${enddate}"/>
</util:map>
if the system parameter is not set, the value in the map should be defaulted to null. How can this be done? I have tried using spring expression language but that was not of much help.
Regards, Daya
Have you tried #{systemProperties['enddate']}
? It does exactly what you want.
PropertyPlaceholderConfigurer
probably has the option to set unresolved properties to null. Apart from that, SpEL supports supports defaults. What have you tried?
精彩评论