Spring EL in XML or ((XML based configuration) by R4R Team

Expression support for defining bean definitions:-
SpEL expressions can be used with XML or annotation-based configuration metadata for defining BeanDefinitions. In both cases the syntax to define the expression is of the form:
#{<expression string>}.


Spring EL in XML((XML based configuration):-
The SpEL are enclosed with #{ SpEL expression }, see below example in XML bean definition file.
 

"http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

id="empBean" class="com.r4r.in.Employee">

"name" value="vipul" />

"age" value="20" />

"studBean" class="com.r4r.in.Student">

"name" value="#{empBean}" />

"studName" value="#{empBean.name}" />

1 #{empBean} – inject “empBean” into “studBean” bean’s “name” property.
2 #{empBean.name} – inject “empBean”‘s “name” property into “studBean” bean’s “studName” property.

 

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!