当前位置: 代码迷 >> J2EE >> 请问web 工程读取xml文件
  详细解决方案

请问web 工程读取xml文件

热度:28   发布时间:2016-04-21 22:35:29.0
请教web 工程读取xml文件
se工程xml配置文件放在src下像代码中这样读就可以了,在web里就不行了
该怎么读呢,xml文件最好放哪儿呢

private IConnectionPool() {
/*SAXReader reader = new SAXReader();
Document doc = null;
try {
File f=new File("/vo.xml");
doc = reader.read(f);
} catch (DocumentException e) {
e.printStackTrace();
}
Element root = doc.getRootElement();
Iterator<Element> ite = root.elementIterator("DataSource");
Element e = ite.next();*/
this.driver="oracle.jdbc.driver.OracleDriver";
this.url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
this.userName="scott";
this.pwd="tiger";
this.maxConnections=150;
this.initalConnection=12;
this.incrementConnections=5;
xml? Web

------解决方案--------------------

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("vo.xml"); 
doc=reader.read(inputStream);
  相关解决方案