考虑下面两个类:
public class Company {
private String name;
private Employee managingDirector;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Employee getManagingDirector() {
return this.managingDirector;
}
public void setManagingDirector(Employee managingDirector) {
this.managingDirector = managingDirector;
}
}
public class Employee {
private float salary;
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
}
下面的代码片断展示了如何获取和设置上面两个示例类 Companies和Employees的属性:
BeanWrapper company = BeanWrapperImpl(new Company());
// setting the company name..
company.setPropertyValue("name", "Some Company Inc.");
// ... can also be done like this:
PropertyValue value = new PropertyValue("name", "Some Company Inc.");
company.setPropertyValue(value);
// ok, let's create the director and tie it to the company:
BeanWrapper jim = BeanWrapperImpl(new Employee());
jim.setPropertyValue("name", "Jim Stravinsky");
company.setPropertyValue("managingDirector", jim.getWrappedInstance());
// retrieving the salary of the managingDirector through the company
Float salary = (Float) company.getPropertyValue("managingDirector.salary");
分享到:
相关推荐
Gwt-Bean 一个使用 JavaScriptObject 的概念,如 Spring BeanWrapper
5.4.1. 设置和获取属性值以及嵌套属性 5.4.2. 内建的PropertyEditor实现 5.4.2.1. 注册用户自定义的PropertyEditor 6. 使用Spring进行面向切面编程(AOP) 6.1. 简介 6.1.1. AOP概念 6.1.2. Spring AOP的功能和目标 ...
5.4.1. 设置和获取属性值以及嵌套属性 5.4.2. 内建的PropertyEditor实现 6. 使用Spring进行面向切面编程(AOP) 6.1. 简介 6.1.1. AOP概念 6.1.2. Spring AOP的功能和目标 6.1.3. Spring的AOP代理 6.2. @...
Spring Framework 开发手册 chm,一份对Spring特性的参考指南,内容涵盖Spring概述、使用场景、Spring2.0新特性、面向切面编程、中间层、WEB层、校验,数据绑定,BeanWrapper,与属性编辑器、使用Spring进行面向...
5.4.1. 设置和获取属性值以及嵌套属性 5.4.2. 内建的PropertyEditor实现 6. 使用Spring进行面向切面编程(AOP) 6.1. 简介 6.1.1. AOP概念 6.1.2. Spring AOP的功能和目标 6.1.3. AOP代理 6.2. @AspectJ支持 ...
5.4.1. 设置和获取属性值以及嵌套属性 5.4.2. 内建的PropertyEditor实现 6. 使用Spring进行面向切面编程(AOP) 6.1. 简介 6.1.1. AOP概念 6.1.2. Spring AOP的功能和目标 6.1.3. AOP代理 6.2. @AspectJ支持 ...
Spring3.0是Spring在积蓄了3年之久后,隆重推出的一个重大升级版本,进一步加强了Spring作为Java领域第一开源平台的翘楚地位。 Spring3.0引入了众多Java开发者翘首以盼的新功能和新特性,如OXM、校验及格式化框架...
背景在 Spring 配置文件中使用 <value.../> 元素来为属性指定属性值,如下面的例子所示:上面的 XML 是如何实现的呢?Spring MVC 数
5.4.1. 设置和获取属性值以及嵌套属性 5.4.2. 内建的PropertyEditor实现 6. 使用Spring进行面向切面编程(AOP) 6.1. 简介 6.1.1. AOP概念 6.1.2. Spring AOP的功能和目标 6.1.3. Spring的AOP代理 6.2. @...
Spring3.0是Spring在积蓄了3年之久后,隆重推出的一个重大升级版本,进一步加强了Spring作为Java领域第一开源平台的翘楚地位。 Spring3.0引入了众多Java开发者翘首以盼的新功能和新特性,如OXM、校验及格式化框架...
NULL 博文链接:https://zhangzhenting.iteye.com/blog/1455511
Spring Framework 开发参考 chm 手册,一份对Spring特性的参考指南,内容涵盖Spring概述、使用场景、Spring2.0新特性、面向切面编程、中间层、WEB层、校验,数据绑定,BeanWrapper,与属性编辑器、使用Spring进行...
BeanWrapper BeanWrapperImpl BeforeAdvice BeforeAdviceAdapter BindErrorsTag BindException BindingErrorProcessor BindingResult BindingResultUtils BindInitializer BindStatus BindTag BindUtils...
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................
熬了半个多月的时间,每天坐在电脑面前十几个小时,从Spring官网拉下来了spring-framework这个项目的源码,边看源码,边从网上找资料,整个项目中使用的设计模式也是非常的经典,如工厂模式:BeanFactory,代理模式...
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................
dpspring 手写弹簧简单框架 豆子 ApplicationContext 简单料理界工厂类 getBean() 从ioc容器中回去一个实例的方法 大流程如下 ...beanWrapper:原生对象和代理对象关联关系 5.完成di 6.handlermapping
│ spring.xml │ struts.xml │ ├─28个java常用的工具类 │ │ Base64.java │ │ Base64DecodingException.java │ │ CConst.java │ │ CharTools.java │ │ ConfigHelper.java │ │ Counter.java │ │ C...