开发者

Injecting Spring Spel Expressions into bean properties

How can I inject a String meant to be a spel expression into an app context bean property without having the context interpret the string property as a spel resolvable value.

<bean id="x" p:spelExpression="${#code}/${#value}"/>

I want the the class's setter property to take a string argument and creates a reusable SpelExpression as a private property of the bean, however, the spring application context appears to be recognizing the #variableName as spel expressions and attempting to interpret the expression at initialization time.

I find Spel interpretation to be very useful, but would like to to use spel internally as well, with expression injection into my own beans.

Is i开发者_高级运维t possible to disable the Spel Interpretation of for a bean, or even for a whole context file (maybe with some namespace shenanigans) without having to disable or modify spel expression resolution for the whole application context.


The #{...} are markers for spel interpreter in xml context.

I don't undestand : ${#code}/${#value}. Good is #{code/value}, as I understand things, if code and value are id.

So, if you want a spel expression without interpret it, put string code/value in xml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜