Spring Framework Documentation (5.3.10)
Core | IoC Container, Events, Resources, i18n, Validation, Data Binding, Type Conversion, SpEL, AOP. |
1. The IoC Container
1.1. Introduction to the Spring IoC Container and Beans(Spring IoC容器和bean简介)
1.2. Container Overview (容器概览)
1.4.1. Dependency Injection(依赖注入)
1.4.2. Dependencies and Configuration in Detail(依赖与配置详细介绍)
1.4.2.1. Straight Values (Primitives, Strings, and so on)(直接值(原始类型、字符串等))
1.4.2.2. References to Other Beans (Collaborators) (引用其他bean(协作者))
1.4.2.5. Null and Empty String Values(Null和空字符串值)
1.4.2.6. XML Shortcut with the p-namespace(p命名空间的XML快捷方式)
1.4.2.7. XML Shortcut with the c-namespace(c-namespace的XML快捷方式)
1.4.2.8. Compound Property Names(复合属性名)
1.4.3. Using depends-on(使用depends-on)
1.4.4. Lazy-initialized Beans(延迟初始化Bean)
1.4.5. Autowiring Collaborators(自动装配协作者)
下载此文档精编完整版
No. | 内容 | 下载地址 | 文档内容目录 |
1 | 中英双语精编版 第一部分 | PDF下载 | 内容目录 |
2 | 中英双语精编版 第二部分 | PDF下载 | 内容目录 |
3 | 中文精编版 第一部分 | PDF下载 | 内容目录 |
4 | 中文精编版 第二部分 | PDF下载 | 内容目录 |
更多章节内容,请点击查看: Core Technologies
1.4.2.8. Compound Property Names(复合属性名)
You can use compound or nested property names when you set bean properties, as long as all components of the path except the final property name are not null
. Consider the following bean definition:
设置bean属性时,可以使用复合属性名或嵌套属性名(compound or nested property name),只要路径的所有组件(最终属性名除外)都不为null。考虑下面的bean定义:
<bean id="something" class="things.ThingOne">
<property name="fred.bob.sammy" value="123" />
</bean>
The something
bean has a fred
property, which has a bob
property, which has a sammy
property, and that final sammy
property is being set to a value of 123
. In order for this to work, the fred
property of something
and the bob
property of fred
must not be null
after the bean is constructed. Otherwise, a NullPointerException
is thrown.
something bean有一个fred属性,fred有一个bob属性,bob
有一个sammy属性,最终的sammy属性被设置为值123。为了使其工作,something的fred属性和fred的bob属性在构建bean后不能为null。否则,将抛出NullPointerException。