当前位置: 代码迷 >> Java Web开发 >> 为何jdom创建失败
  详细解决方案

为何jdom创建失败

热度:4197   发布时间:2013-02-25 21:15:20.0
为啥jdom创建失败?
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,问题出在哪里呢?

------解决方案--------------------------------------------------------
贴错误信息啊
  相关解决方案