集合 Properties 的 简单例子(Spring)
Java代码:
package com.ioc; import java.util.Properties; public class Student {
private String name;
private int age;
Properties Pp;
public Properties getPp() {
return Pp;
}
public void setPp(Properties pp) {
Pp = pp;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
} }
package com.ioc; import java.util.Map.Entry;
import java.util.Properties; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource; public class Test { public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("com/ioc/beans.xml");
Student s = (Student) ac.getBean("student"); Properties pp = s.getPp();
for(Entry<Object, Object> e:pp.entrySet())
{
System.out.println(e.getKey().toString()+" "+e.getValue().toString());
} } }
XML代码:
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="student" class="com.ioc.Student">
<property name="name" value="lihao" />
<property name="age" value="24" /> <property name="pp">
<props>
<prop key="pp1">aaa</prop>
<prop key="pp2">bbb</prop>
<prop key="pp3">ccc</prop>
</props> </property>
</bean> </beans>
集合 Properties 的 简单例子(Spring)的更多相关文章
- 【Spring】简单的Spring MVC入门例子
前言 测试特性需要搭建一个简单的Spring MVC的例子,遂记录之,只是例子,只为入门者之示例. 版本说明 声明POM文件,指定需引入的JAR. <properties> <spr ...
- Spring框架系列(2) - Spring简单例子引入Spring要点
上文中我们简单介绍了Spring和Spring Framework的组件,那么这些Spring Framework组件是如何配合工作的呢?本文主要承接上文,向你展示Spring Framework组件 ...
- spring mvc(注解)上传文件的简单例子
spring mvc(注解)上传文件的简单例子,这有几个需要注意的地方1.form的enctype=”multipart/form-data” 这个是上传文件必须的2.applicationConte ...
- c# spring aop的简单例子
刚刚完成了一个c#的spring aop简单例子,是在mac下用Xamarin Studio开发的.代码如下: 接口 using System; using System.Collections.Ge ...
- 一个简单的Spring测试的例子
在做测试的时候我们用到Junit Case,当我们的项目中使用了Sring的时候,我们应该怎么使用spring容器去管理我的测试用例呢?现在我们用一个简单的例子来展示这个过程. 1 首先我们新建一个普 ...
- 1.Spring IoC简单例子
Spring IoC简单例子 1.IHelloMessage.java package com.tony.spring.chapter01; public interface IHelloMessag ...
- spring容器BeanFactory简单例子
在Spring中,那些组成你应用程序的主体及由Spring Ioc容器所管理的对象,都被称之为bean.简单来讲,bean就是Spring容器的初始化.配置及管理的对象.除此之外,bean就与应用程序 ...
- 简单了解Spring中常用工具类_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 文件资源操作 Spring 定义了一个 org.springframework.core.io.Resource 接口, ...
- 阿里RocketMq试用记录+简单的Spring集成
CSDN学院招募微信小程序讲师啦 程序猿全指南,让[移动开发]更简单! [观点]移动原生App开发 PK HTML 5开发 云端应用征文大赛,秀绝招,赢无人机! 阿里RocketMq试用记录+简单的S ...
随机推荐
- SAP云平台,区块链,超级账本和智能合约
前一篇文章<Hyperledger Fabric on SAP Cloud Platform>,我的同事Aviva已经给大家介绍了基于区块链技术的超级账本(Hyperledger)的一些概 ...
- (转)MyBatis框架的学习(四)——Mapper.xml文件中的输入和输出映射以及动态sql
http://blog.csdn.net/yerenyuan_pku/article/details/71893689 前面对MyBatis框架的学习中,我们对Mapper.xml映射文件多少有些了解 ...
- glob - 形成路径名称
描述 (DESCRIPTION) 很久以前 在 UNIX V6 版 中 有一个 程序 /etc/glob 用来 展开 通配符模板. 不久以后 它 成为 shell 内建功能. 现在 人们 开发了 类似 ...
- JavaScript中的显示原型和隐形原型(理解原型链)
显式原型:prototype 隐式原型:__proto__ 1.显式原型和隐式原型是什么? 在js中万物皆对象,方法(Function)是对象,方法的原型(Function.prototype)是对象 ...
- jQuery-AJAX简介
AJAX是浏览器后台与服务器交换数据的技术,无须加载整个页面的情况下,对页面中的局部进行更新. AJAX=异步的JavaScript与XML(Asynchronous JavaScript and X ...
- 标准C中字符串分割方法
◆ 使用strtok函数分割. 原型:char *strtok(char *s, char *delim); strtok在s中查找包含在delim中的字符并用NULL('\0')来替换,直到找遍整个 ...
- luogu 2296 寻找道路 (搜索)
luogu 2296 寻找道路 题目链接:https://www.luogu.org/problemnew/show/P2296 从终点bfs或者dfs,找出所有终点能到达的点. 然后再从1到n看一下 ...
- Linux基础学习系列目录导航
Linux基础学习-通过VM安装RHEL7.4 Linux基础学习-命令行与图形界面切换 Linux基础学习-基本命令 Linux基础学习-RHEL7.4之YUM更换CentOS源 Linux基础学习 ...
- CSS3的-字体 @font-face
http://www.w3cplus.com/content/css3-font-face http://www.w3cplus.com/css3/web-icon-with-font-face ht ...
- LCD驱动分析(二)帧缓冲设备作为平台设备
参考:S3C2440 LCD驱动(FrameBuffer)实例开发<一> S3C2440 LCD驱动(FrameBuffer)实例开发<二> 1.平台设备注册 1.1在li ...