xml解析

Java中配置文件的三种配置位置及读取方式

1.XML和.properties(属性文件)
2.存放位置
1.1 src根目录下
Xxx.class.getResourceAsStream("/config.properties");
xml解析
1.2 与读取配置文件的类在同一包
Xxx.class.getResourceAsStream(“config2.properties”);
xml解析
xml解析
1.3 WEB-INF(或其子目录下)
ServletContext application = this.getServletContext();
InputStream is = application.getResourceAsStream("/WEB-INF/config3.properties");
xml解析
xml解析
xml解析

xml解析

properties文件的解析方式有java.util.properties这个类来完成
xml文件:应该有一个工具类来完成
jdk/jdom
sax解析 由上往下解析
dom4j解析 由外到内解析
xml解析
xml解析
以上比较麻烦
以下简单的
xml解析