dom4j读取配置文件
来源:互联网 发布:淘宝店打折怎么设置 编辑:程序博客网 时间:2024/06/05 23:44
1.创建xml存放数据
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="utf-8"/> <property name="maxUploadSize" value="10485760000"/> <property name="maxInMemorySize" value="40960"/> </bean>
2.dom4j读取
public void getXmlData(String filename){ SAXReader saxReader = new SAXReader(); Document document = null; try{ URL xmlpath = this.getClass().getClassLoader().getResource(filename); System.out.println(xmlpath); document = saxReader.read(xmlpath); Map<String,String> nsMap = new HashMap<String,String>(); nsMap.put("ns","http://www.springframework.org/schema/beans"); XPath xsub = document.createXPath("//ns:beans/ns:bean"); xsub.setNamespaceURIs(nsMap); List<Element> beans = xsub.selectNodes(document); for(Element element:beans){ String id = element.attributeValue("id"); String clazz = element.attributeValue("class"); System.out.println("id-->"+id+" class-->"+clazz); XPath propertyxsub = element.createXPath("ns:property"); propertyxsub.setNamespaceURIs(nsMap); List<Element> propertys = propertyxsub.selectNodes(element); for(Element property: propertys){ String propertyName = property.attributeValue("name"); String propertyvalue = property.attributeValue("value"); System.out.println("propertyName-->"+propertyName+" properyvalue-->"+propertyvalue); } } }catch(Exception e){ e.printStackTrace(); } }
阅读全文
0 0
- dom4j读取spring配置文件
- dom4j读取配置文件
- dom4j读取配置文件
- dom4j读取配置文件
- XML配置文件的读取--DOM4J
- 使用dom4j读取spring配置文件
- 利用dom4j读取XML配置文件
- 使用dom4j读取xml配置文件
- dom4j实现模拟Spring读取配置文件 注入
- dom4j 读取xml 数据库配置文件 dataconfig
- DOM4J 读取XML配置文件进行数据库连接
- drp—Dom4j读取xml配置文件
- 用dom4j读取配置文件来模拟spring的bean工厂
- Java读取XML配置文件详细总结(dom4j方式)
- Java中通过dom4j读取配置文件实现抽象工厂+反射
- Java中通过dom4j读取配置文件实现抽象工厂+反射
- Java中通过dom4j读取配置文件实现抽象工厂+反射
- 使用dom4j模拟spring工厂来读取配置文件
- eclipse复制黏贴jar时弹出:cannot paste the clipboard contents
- C/C++线性表---顺序表算法全解析
- HTML5优秀案例、酷炫特效
- centos7.0 svn安装及设置自动启动
- spring boot+hibernate+thymeleaf 练习
- dom4j读取配置文件
- mysql建外键
- 【yolo v2】训练自己数据集
- android 定制Toast消息的位置
- C#报无法将 Owner 属性设置为之前未显示的 Window错误
- 链表创建和链表遍历算法
- 调整图像亮度和对比度
- android下的XMPP对应smack-4.2.1,实现登录,注册,发单聊,加聊天室,发群聊等简单功能
- APP广告弹窗