spring&dom4j
来源:互联网 发布:淘宝和天猫客户端 编辑:程序博客网 时间:2024/05/29 15:50
一、技术:DOM4J
1.1)DOM4J简介:用于读取XML文件
1.2)读取配置文件需要的jar包:官网下载: http://www.dom4j.org/dom4j-1.6.1/
1.3)dom4j相关方法介绍:
(1).获取XML文档(Document类型)
SAXReader reader=new SAXReader();
//读取xml文件的方式,当然,除了以下提及的还有很多重载方法,可以在在开发工具或者API中查看
//1.文件参数读取
Document document=reader.read(File file);//根据路径创建FIle对象
//根据输入流获取xml文件
类名.class.getResourceAsStream(String path);
Document document=reader.read(InputStream input);
(2)获取文档根节点
Element element=document.getRootElement();
(3)获取根节点的名称
String name=element.getName();
(4)获取某个节点(node)下的所有子节点
List list=node.elements();
(5)获取某个节点下的某个子节点(Element类型)
node.element("节点名称")
(6)取得某节点下的某属性
node.attribute("属性名称");
(7)获得某节点的某属性的值
node.attribute(“属性名称”).getText();
二、简单实例(模拟spring容器创建对象)
//两个实体类
FirstBean
SecondBean
//BeanFactory
//ClassPathXmlApplicationContext
//spring配置文件
- spring&dom4j
- dom4j读取spring配置文件
- dom4j解析spring.xml
- 使用dom4j读取spring配置文件
- dom4j实现模拟Spring读取配置文件 注入
- dom4j解析spring.xml 对象解析(二)
- Dom4j
- dom4j
- DOM4J
- DOM4j
- Dom4j
- Dom4j
- dom4j
- dom4j
- dom4j
- dom4j
- dom4j
- dom4j
- 视频监控相关研究方向
- POJ-2407-Relatives-欧拉函数
- mysql select into table
- 更新cocoaPods
- Latent semantic analysis note(LSA)
- spring&dom4j
- BOM字符串匹配算法
- C语言简单函数应用:数学计算
- Java线程池 ExecutorService
- 自定义UITabBar 在 popToViewController 或popToRootViewController后UITabBarItem出现重叠
- STM32IAP升级-----编写IAP升级遇到的问题总结
- OC 常用类 --- NSDate
- Android程序猿挑战高薪必会的十大面试题
- mappingResources,annotatedClasses(映射)