Spring系列【08】为JavaBean的集合对象注入属性值
2014-12-14 22:23
423 查看
TestUtil.java
Spring配置文件
这个比较简单,就不再重复了。
package com.lh.util; import java.util.List; import java.util.Map; import java.util.Set; public class TestUtil { @Override public String toString() { return "TestUtil [list=" + list + ", set=" + set + ", map=" + map + "]"; } private List<?> list; private Set<?> set; private Map<?, ?> map; public void setList(List<?> list) { this.list = list; } public void setSet(Set<?> set) { this.set = set; } public void setMap(Map<?, ?> map) { this.map = map; } public List<?> getList() { return list; } public Set<?> getSet() { return set; } public Map<?, ?> getMap() { return map; } }
Spring配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> <bean id="testUtil" class="com.lh.util.TestUtil"> <property name="list"> <list> <value>list集合的第一个元素</value> <value>list集合的第二个元素</value> <value>list集合的第三个元素</value> </list> </property> <property name="set"> <set> <value>张三*</value> <value>李四*</value> </set> </property> <property name="map"> <map> <entry key="key1" value="Java从基础到项目实战" /> <entry key="key2" value="JavaWeb从基础到项目实战" /> </map> </property> </bean> </beans>
这个比较简单,就不再重复了。
相关文章推荐
- spring:为javabean的集合对象注入属性值
- 【Spring】【对<bean>注入各种信息】【简单属性,对象属性,集合属性,构造器】
- Spring 2.0中集合对象注入的复用
- 快速上手Spring--8. 集合对象注入
- 完美解决Java中List集合去除重复的JavaBean对象某些属性值方案
- Spring 自学系列之IOC-7【collection集合注入】
- Spring -------集合对象注入
- Spring整理系列(02)——spring依赖注入,组装对象之间的依赖关系
- Spring (三)注入依赖对象、注入集合类型的属性
- 快速上手Spring--8. 集合对象注入
- 快速上手Spring--8. 集合对象注入
- 【JavaEE学习笔记】Spring_02_IoC/DI依赖注入,集合对象属性注入,自动装配,代理模式
- Spring入门10 - 集合对象注入
- 快速上手Spring--8. 集合对象注入
- SPRING.NET 1.3.2 学习21--使用对象或类的属性值进行注入
- spring 集合注入方式
- Spring.NET教程(七)——集合类型的注入(基础篇)
- WebSphere6.x中不能使用Spring的session scope注入对象的解决办
- Spring中的依赖注入——集合注入
- springJDBC中对象自动封装到集合中