Spring -配置集合属性
1 可使用<list> <map> <set>等来配置集合属性
2 List
<!-- 配置List属性 -->
<bean id="person3" class="com.kejian.spring.bean.collectionbean.PersonForList">
<property name="name" value="Peter"></property>
<property name="age" value="30"></property>
<property name="cars">
<list>
<ref bean="car1"/>
<ref bean="car2"/>
</list>
</property>
</bean>
3 Map
<!-- 配置Map属性 -->
<bean id="person4" class="com.kejian.spring.bean.collectionbean.PersonForMap">
<property name="name" value="Mike"></property>
<property name="age" value="35"></property>
<property name="cars">
<map>
<entry key="ACar" value-ref="car1"></entry>
<entry key="BCar" value-ref="car2"></entry>
</map>
</property>
</bean>
4 Props:配置properties
<!-- 通过props来配置properties -->
<bean id="datasource" class="com.kejian.spring.bean.collectionbean.Datasource">
<property name="properties">
<props>
<prop key="user">root</prop>
<prop key="password">root</prop>
<prop key="url">jdbc:mysql.///test</prop>
<prop key="driver">jdbc.mysql.driver</prop>
</props>
</property>
</bean>
5 单独配置集合bean:需引入Util shema
<!-- 单独配置集合 -->
<util:list id="cars">
<ref bean="car1"/>
<ref bean="car2"/>
</util:list>
6 使用p shema更快捷配置bean属性:需引入p shema
<!-- 通过p命名空间来配置bean属性 -->
<bean id="person5" class="com.kejian.spring.bean.collectionbean.PersonForList"
p:name="Jack" p:age="22" p:cars-ref="cars">
</bean>
Spring -配置集合属性的更多相关文章
- Spring基础07——配置集合属性
1.集合属性 在Spring中可以通过一组内置的xml标签(例如<list>,<set>或<map>)来配置集合属性. 2.配置List集合 配置java.util ...
- Spring学习--集合属性
Spring 中可以通过一组内置的 xml 标签(例如: <list> , <set> 或 <map>) 来配置集合属性. 配置java.util.Set 需要使用 ...
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- spring 配置属性的详细信息
摘要(这篇文章讲的红,蓝说这话节) 字面值 字面值:可用字符串表示的值,能够通过<value>元素标签或value属性进行注入 基本数据类型及其封装类.String等类型都能够採取字面值注 ...
- Spring(八):Spring配置Bean(一)BeanFactory&ApplicationContext概述、依赖注入的方式、注入属性值细节
在Spring的IOC容器里配置Bean 配置Bean形式:基于xml文件方式.基于注解的方式 在xml文件中通过bean节点配置bean: <?xml version="1.0&qu ...
- Spring容器的属性配置详解的六个专题
在spring IOC容器的配置文件applicationContext.xml里,有一些配置细节值得一提.我们将一些问题归结为以下几个专题. 专题一:字面值问题 配置的bean节点中的值,我们提 ...
- spring 配置属性细节
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/qilixiang012/article/details/28233811 概要(红色为上一篇所讲,蓝 ...
- spring 配置bean
Main(测试方法) public class Main { public static void main(String[] args) { //1.创建Spring 的IOC容器对象: //spr ...
- Spring4学习笔记2-配置集合属性
1 可使用<list> <map> <set>等来配置集合属性 2 List <!-- 配置List属性 --> <bean id="p ...
随机推荐
- 【Python】range和xrange区别
转自:http://www.cnblogs.com/zhangjing0502/archive/2012/05/16/2503880.html range 函数说明:range([start,] ...
- 【XLL 文档翻译】【第2部分】C API 回调函数 Excel4, Excel12
Excel4 和 Excel12 函数使得 DLL 可以调用 Excel 工作表函数.宏表函数.命令.XLL特定函数或命令.最近的一些 Excel 版本都支持 Excel12 函数.这两个函数支持下面 ...
- 导出 SQL SERVER 表中数据为脚本
ALTER PROCEDURE [dbo].[Usp_OutputData] @tablename sysname, @outputIdentitycolumn int AS declare @col ...
- supersr--NSURLConnection iOS2.0苹果原生请求
get请求1: NSURL*url = [NSURLURLWithString:@"http://127.0.0.1/demo.json"]; NSURLRequ ...
- java动态生成excel打包下载
@SuppressWarnings("unchecked") public String batchExport() throws DBException{ @SuppressWa ...
- linux crontab 学习
安装crontab:[root@CentOS ~]# yum install vixie-cron[root@CentOS ~]# yum install crontabs/sbin/service ...
- NYOJ题目11613n+1问题
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAscAAAIvCAIAAAAXg+GWAAAgAElEQVR4nO3dO1LryNsH4G8T5CyE2A ...
- JS 获取浏览器窗口大小
JS 获取浏览器窗口大小 <script> // 获取窗口宽度 if (windows.innerWidth) { winWidth = windows.innerWidth; } els ...
- iOS开发Xcode7真机调试教程
从Xcode7开始,Xcode 不需要$99/$299升级开发者直接可以进行真机调试 调试步骤 1.假设已经你已经有了苹果账号,下载并安装好了Xcode7 2. 打开Xcode-> Prefer ...
- MVC学习笔记---MVC框架执行顺序
一.把路由添加到路由表, 二.注册ControllerBuilder(老板)和默认工厂(DefaultControllerFactory) 2.1默认工厂获取可以创建的Controller. 三.由于 ...