Source Code BasicEL Demo
Source Code BasicEL Demo
ApplicationContext context = new ClassPathXmlApplicationContext("app.xml"); testA obj = (testA) context.getBean("a"); System.out.println(obj.getName2()); System.out.println(obj.getBb()); }
package com; public class testA { private testB bb; public testB getBb() { return bb; } public void setBb(testB bb) { this.bb = bb; } public String getName2() { return name2; } public void setName2(String name2) { this.name2 = name2; } private String name2; }
private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getQty() { return qty; } public void setQty(int qty) { this.qty = qty; } private int qty; }
<bean id="b" class="com.testB"> <property name="name" value="Abcddd" /> <property name="qty" value="10" /> </bean> <bean id="a" class="com.testA"> <property name="bb" value="#{b}" /> <property name="name2" value="#{b.name}" /> </bean> </beans>