Spring EL template in a spring bean definition -


i have bean has map injected. entries in map of type mybean (see below) , defined in spring xml. may not properties of mybean defined in xml, thought provide defaults in form of template variable bit in template provided property present (p1 below). hope makes sense.

i sure there other ways achieve this; well, know there are, new spring , came across spring el , sounded suited kind of thing, tried this:

            <bean id="mydefaults" class="com.myco.mydefaults">               <property name="prop1" value="abc#{this.p1}def"/>             </bean>              <bean id="mybean" class="com.myco.mybean" abstract="true">                             <property name="thedefaults" ref="mydefaults"/>             </bean> 

in mybean value of p1 100, , hoping value of thedefaults abc100def, instead error:

error creating bean name 'mydefaults' defined in class path resource [myapp-spring.xml]: initialization of bean failed; nested exception org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1008e:(pos 0): field or property 'this' cannot found on object of type 'org.springframework.beans.factory.config.beanexpressioncontext' 

thanks help

paul

the variable #this, not this in case, it's not needed in context, it's implied.

use value="abc#{p1}def"


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -