dom读xml异常求救 csdn这是怎么了,以往繁荣的景象到哪去了,还是人们已经厌倦了,发出的帖子就象石沉大海一样,真是让人心寒 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 补充一下,问题出在test.jsp的 users =doc.getElementsByTagName("link");这句语句上,把它注释掉就没问题,为什么??? 显然是你的路径有问题啊doc=xmlBean.connXml(requeat.getContextPath()+"/links.xml"); 按照楼上的说法改为doc=xmlBean.connXml(request.getContextPath()+"/links.xml");仍然报相同的错误 应该先用 getRootElement() 方法得到XML根节点然后再在根节点基础上进行下一步操作Elements root;root=doc.getRootElement;users =root.getElementsByTagName("link");随手写的,不知道有没有用法错误,就是这个意思 把XML文件内容写上来吧我上面讲错了有可能就是没有根节点的 xml如下:<?xml version="1.0" standalone="yes"?><links> <link> <text>JSP Insider</text> <url newWindow="no">http://www.jspinsider.com</url> <author>JSP Insider</author> <date> <day>2</day> <month>1</month> <year>2001</year> </date> <description>A JSP information site.</description></link><link><text>The makers of Java</text><url newWindow="no">http://java.sun.com</url><author>Sun Microsystems</author><date><day>3</day><month>1</month><year>2001</year></date><description>Sun Microsystem's website.</description></link><link><text>The standard JSP container</text><url newWindow="no">http://jakarta.apache.org</url><author>Apache Group</author><date><day>4</day><month>1</month><year>2001</year></date><description>Some great software.</description></link></links> links就是根节点Elements links;links=doc.getRootElement;users =root.getElementsByTagName("link"); doc=xmlBean.connXml("links");这里的links是什么含意 因为 doc是 Document对象 这里应该是跟文件名有关的,不要和XML文件里面的links弄混 问题解决,很奇怪在JAVA里面doc=xmlBean.connXml("links.xml");可以正常连接XML文件,但是在JSP里面就非得改成doc=xmlBean.connXml("/links.xml");就这个路径折磨了我一下午!揭帖给分!! EL表达式好像不支持,请帮忙 为何到了支付宝收银台页面出现了乱码 jsp动作指令param传参乱码问题 防止struts2自动赋值的问题 Struts2拦截器问题 初学hibernate遇到一个主键问题,各位兄弟帮帮忙! 关于数据库查询的问题,在线等,求帮助 服务端IP绑定的问题 Jsp+servlet+javabean成熟系统源码(有在线演示),绝非网络流传的一般代码 ejb入门问题javax.naming.NoInitialContextException 请问:为什么在在JDK1.4上运行正常的程序,在JDK1.5上连接数据库确很慢呢? 开始学J2EE的基础配置
这句语句上,把它注释掉就没问题,为什么???
doc=xmlBean.connXml(requeat.getContextPath()+"/links.xml");
root=doc.getRootElement;
users =root.getElementsByTagName("link");随手写的,不知道有没有用法错误,就是这个意思
<?xml version="1.0" standalone="yes"?>
<links>
<link>
<text>JSP Insider</text>
<url newWindow="no">http://www.jspinsider.com</url>
<author>JSP Insider</author>
<date>
<day>2</day>
<month>1</month>
<year>2001</year>
</date>
<description>A JSP information site.</description>
</link>
<link>
<text>The makers of Java</text>
<url newWindow="no">http://java.sun.com</url>
<author>Sun Microsystems</author>
<date><day>3</day>
<month>1</month>
<year>2001</year>
</date>
<description>Sun Microsystem's website.</description>
</link>
<link>
<text>The standard JSP container</text>
<url newWindow="no">http://jakarta.apache.org</url>
<author>Apache Group</author>
<date>
<day>4</day>
<month>1</month>
<year>2001</year>
</date>
<description>Some great software.</description>
</link>
</links>
links=doc.getRootElement;
users =root.getElementsByTagName("link");
links弄混