分类: 系统运维
2005-08-28 14:25:17
将xloadtree的Demo直接放置到Tomcat的Webapps目录下,不能正确显示,总显示“Error Load tree.xml”,一步步对问题进行了跟踪,找到了问题的所在。问题在于XmlHttp使用了responseXML,返回的消息必须是xml,更准确的说是必须能够被识别为xml,要做到这点其实很简单,只要设置ContentType="test/xml"。
我的做法是对xml用jsp进行了包装:
tree.xml |
|
tree.jsp | <% response.setContentType("text/xml"); out.println(" " + " " + " " " " " " " " " %> |
tree1.xml |
|
tree1.jsp | <% response.setContentType("text/xml"); out.println(" " + " " + " " " " " " " " " " " " " " " " " %> |
tree2.xml |
|
tree2.jsp | <% response.setContentType("text/xml"); out.println(" " + " " + " " " " " " " " %> |
emptytree.xml | |
emptytree.jsp | <% response.setContentType("text/xml"); out.println(" " + " %> |
这样就能够正确的显示树图了,这种方法比较适合动态的通过程序获取树图。
还有种比较彻底的办法,更改xloadtree关于xmlhttp的部分。