Spring Bean的属性注入
在spring中bean的属性注入有两种
构造器注入
"car" class="nwtxxb.di.Car">"0" type="java.lang.String" value="保时捷"> "1" type="double" value="2000000">
Setter方法注入
id="car" class="nwtxxb.di.Car"><property name="name" value="捷豹"/><property name="price" value="500000"/>
集合属性的注入
在spring中对于集合属性,可以使用专门的标签来完成注入.
例如:list set map properties等集合元素来完成集合属性注入.
List属性注入
如果属性是数组类型也可以使用list完成注入
Set属性注入
Map属性注入
Properties属性注入
Java.util.Properties是java.util.Map的实现类,它的key与value都是String类型.
<props><prop key="company">nwtxxbprop><prop key="price">100000prop>
props>
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
