Spring ListFactoryBean实例
package com.yiibai.common; import java.util.List; public class Customer
{
private List lists;
//...
}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="CustomerBean" class="com.yiibai.common.Customer">
<property name="lists">
<bean class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="targetListClass">
<value>java.util.ArrayList</value>
</property>
<property name="sourceList">
<list>
<value>one</value>
<value>2</value>
<value>three</value>
</list>
</property>
</bean>
</property>
</bean> </beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd"> <bean id="CustomerBean" class="com.yiibai.common.Customer">
<property name="lists">
<util:list list-class="java.util.ArrayList">
<value>one</value>
<value>2</value>
<value>three</value>
</util:list>
</property>
</bean> </beans>
Caused by: org.xml.sax.SAXParseException:
The prefix "util" for element "util:list" is not bound.
执行,查看结果:
package com.yiibai.common; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; public class App {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml"); Customer cust = (Customer) context.getBean("CustomerBean");
System.out.println(cust); }
}
输出结果
Customer [lists=[one, 2, three]] Type=[class java.util.ArrayList]
Spring ListFactoryBean实例的更多相关文章
- spring得到实例和new一个实例,哪个快?
spring配置的bean是默认单例,那么在程序中,得到一个实例一定比创建一个实例的速度快,也更加省资源.今天实际测试的时候发现,new 一个对象比spring得到一个对象快多了.后面自己又加了个单例 ...
- Spring Security4实例(Java config版)——ajax登录,自定义验证
本文源码请看这里 相关文章: Spring Security4实例(Java config 版) -- Remember-Me 首先添加起步依赖(如果不是springboot项目,自行切换为Sprin ...
- Spring Security4实例(Java config 版) —— Remember-Me
本文源码请看这里 相关文章: Spring Security4实例(Java config版)--ajax登录,自定义验证 Spring Security提供了两种remember-me的实现,一种是 ...
- Spring Aop实例@Aspect、@Before、@AfterReturning@Around 注解方式配置
用过spring框架进行开发的人,多多少少会使用过它的AOP功能,都知道有@Before.@Around和@After等advice.最近,为了实现项目中的输出日志和权限控制这两个需求,我也使用到了A ...
- SSH---整合Struts2&Spring&Hibernate(实例)
一.SSH回顾 Struts2:核心为过滤器+拦截器.过程:Filter--->FilterDispatcher-->ActionMapper-->ActionProxy--> ...
- Spring事物实例
Spring事务实例: entity实体类: public class Accounts { private int accountid; private String accountname; pr ...
- Spring登录实例
Spring登录实例 项目结构 首先看一下整个项目的目录结构,如下: 导入Jar包 工欲善必先利其器,导入一下Jar包 配置文件 web.xml 配置 web.xml配置文件,如下: xmlns:xs ...
- Spring AOP实例——异常处理和记录程序执行时间
实例简介: 这个实例主要用于在一个系统的所有方法执行过程中出线异常时,把异常信息都记录下来,另外记录每个方法的执行时间. 用两个业务逻辑来说明上述功能,这两个业务逻辑首先使用Spring AOP的自动 ...
- [Spring框架]Spring开发实例: XML+注解.
前言: 本文为自己学习Spring记录所用, 文章内容包括Spring的概述已经简单开发, 主要涉及IOC相关知识, 希望能够对新入门Spring的同学有帮助, 也希望大家一起讨论相关的知识. 一. ...
随机推荐
- Python os模块和sys模块 操作系统的各种接口
一.os模块 这个模块提供了一个便携式去使用操作系统的相关功能,如果只是想操作路径,请参阅os.path模块. ''' os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 ...
- 在rhel7上搭建centos7的yum源
1. 再查看现在主机上的yum源,并将它们删除 [root@localhost ~]# rpm -qa|grep yum | xargs rpm -e --nodeps # --nodeps 不管有没 ...
- Tutorial 2: Requests and Responses
转载自:http://www.django-rest-framework.org/tutorial/2-requests-and-responses/ Tutorial 2: Requests and ...
- Vue进阶篇
前引 今天是2018年12月30,虽不是2018年的最后一天,但是却是自己在2018年写的最后一篇博客了,昨天下班在地铁上闲来无事,翻起了关注的一些公众号发的技术博文,里面就提到写博客的重要性,其实这 ...
- linux中的vim 编辑一行内容,如何使光标快速移动到行首和行尾以及行中间某处啊?
光标定位G 移至行行首nG 移至第n行行首n+ 移n行行首n- 移n行行首n$ 移n行(1表示本行)行尾0 所行行首$ 所行行尾^ 所行首字母h,j,k,l 左移移移右移H 前屏幕首行行首M 屏幕显示 ...
- 通过EPROCESS获取进程名
上一篇写自我保护时用到了,主要是不同版本的位置不同.找了一下,发现XP和win7的情况分别如下. WIN7 lkd> dt nt!_EPROCESS +0x000 Pcb : _KPROCESS ...
- 如何关闭WordPress后台的主题、插件、版本更新通知?
由于WordPress 更新速度非常快,不论是主题 插件或是版本,每个月少说要执行个好几次,因为更新快,所以WordPress后台加入了更新通知,提醒使用者有新版本了,可以进行插件.主题或是系统更新, ...
- 【51nod】1227 平均最小公倍数
题解 这个故事告诉们数论函数不要往分式上跑,你推不出来 好久没推式子了这么明显的转化我都忘了= = 首先\(A(n) = \frac{1}{n} \sum_{i = 1}^{n} \frac{i * ...
- PyQt5点击按钮产生新窗体
import sys from PyQt5.QtWidgets import QApplication,QWidget from form1 import Ui_Form1 from form2 im ...
- CF986B Petr and Permutations [逆序对]
题目传送门 Petr and Permutations 格式难调,题面就不放了. 分析: 胡乱分析+猜测SP性质一波.然后被学长告知:“1~n的排列交换次数与逆序对的奇偶性相同.”然后就愉快地A了. ...