- Java code
SAXBuilder sb=new SAXBuilder(); URL cl = Client.class.getClassLoader().getResource(""); base = cl.getPath(); base = str_trim(base,"/"); base = base.replace("classes", ""); doc = sb.build(new FileInputStream( base + "client.xml")); root = doc.getRootElement();
我先说一下base + "client.xml"的结果:
"D:\Program Files\Apache Software Foundation\apache-tomcat-7.0.27\webapps\WebContent\WEB-INF\client.xml"
路径感觉没问题啊!client.xml正是放在WEB-INF下
下面是client.xml文件内容:
- XML code
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"><clients><client name="win32fan" key="8273f9a4830487d0fd67eefa1f05423e"></client></clients>
经我断点调试,发现doc==null,问题出在哪里呢?
------解决方案--------------------------------------------------------
贴错误信息啊