Sam
Sam

Reputation: 6900

I have a string contains ${key} in spring context

I have a simple spring context as following:

<bean id="acl.authentication.provider" class="comprovider.ProviderType" factory-method="getInstance">
    <constructor-arg index="0" value="${key}"/>
</bean>

${key} isn't a property place holder, it's my real string but spring want fetch it from a property place holder and can't found it so throws a exception. What can I using ${} as my real string in spring context?

Upvotes: 2

Views: 133

Answers (1)

benzonico
benzonico

Reputation: 10833

I am not really sure it works (because I don't have what to test it at hand) but I think you can trick spring el evaluator by doing the following :

<bean id="acl.authentication.provider" class="comprovider.ProviderType" factory-method="getInstance">
    <constructor-arg index="0" value="#{'$'+'{key}'}"/>
</bean>

Upvotes: 4

Related Questions