xloadtree Demo本地使用问题
2005-10-12 01:18
363 查看
xloadtree的Demo可以从http://webfx.eae.net/dhtml/xloadtree/xloadtree.html下载,并有usage,api...
将xloadtree的Demo直接放置到Tomcat的Webapps目录下,不能正确显示,总显示“Error Load tree.xml”,一步步对问题进行了跟踪,找到了问题的所在。问题在于XmlHttp使用了responseXML,返回的消息必须是xml,更准确的说是必须能够被识别为xml,要做到这点其实很简单,只要设置ContentType="test/xml"。
我的做法是对xml用jsp进行了包装:
tree.xml <?xml version="1.0" encoding="UTF-8"?>
<tree>
<tree text="Load "tree1.xml"" src="tree1.xml" />
<tree text="Loaded Item 1" action="http://webfx.eae.net" />
<tree text="Loaded Item 2">
<tree text="Loaded Item 2.1" action="javascript:alert(2.1)" />
</tree>
<tree text="Loaded Item 3 (with target)" action="http://www.google.com" target="_new" />
<tree text="Load "tree1.xml"" src="tree1.xml" />
</tree>
tree.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Load "tree1.xml"/" src=/"tree1.jsp/" />/n" +
"/t<tree text=/"Loaded Item 1/" action=/"http://webfx.eae.net/" />/n" +
"/t<tree text=/"Loaded Item 2/">/n" +
"/t/t<tree text=/"Loaded Item 2.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t</tree>/n" +
"/t<tree text=/"Loaded Item 3 (with target)/" action=/"http://www.google.com/" target=/"_new/" />/n" +
"/t<tree text=/"Load "tree1.xml"/" src=/"tree1.jsp/" />/n" +
"</tree>");
%>
tree1.xml <?xml version="1.0"?>
<tree>
<tree text="Loads tree2.xml" src="tree2.xml"/>
<tree text="Loads NOT_AVAILABLE.xml" src="NOT_AVAILABLE.xml"
icon="images/xp/folder.png"/>
<tree text="Loads emptytree.xml" src="emptytree.xml"
icon="images/xp/folder.png"/>
<tree text="Loaded Item 3" action="javascript:alert(3)" />
<tree text="Loaded Item 4" action="javascript:alert(4)">
<tree text="Loaded Item 4.1" action="javascript:alert(2.1)" />
<tree text="Loaded Item 4.2">
<tree text="Loaded Item 4.2.1">
<tree text="Loaded Item 4.2.1.2"/>
<tree text="Loaded Item 4.2.1.3"/>
</tree>
<tree text="Loaded Item 4.2.2"/>
</tree>
</tree>
<tree text="WebFX Home" action="http://webfx.eae.net"
icon="http://webfx.eae.net/images/favicon.gif"/>
</tree>
tree1.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Loads tree2.xml/" src=/"tree2.jsp/"/>/n" +
"/t<tree text=/"Loads NOT_AVAILABLE.xml/" src=/"NOT_AVAILABLE.xml/"/n" +
"/t/ticon=/"images/xp/folder.png/"/>/n" +
"/t<tree text=/"Loads emptytree.xml/" src=/"emptytree.jsp/"/n" +
"/t/ticon=/"images/xp/folder.png/"/>/n" +
"/t<tree text=/"Loaded Item 3/" action=/"javascript:alert(3)/" />/n" +
"/t<tree text=/"Loaded Item 4/" action=/"javascript:alert(4)/">/n" +
"/t/t<tree text=/"Loaded Item 4.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t/t<tree text=/"Loaded Item 4.2/">/n" +
"/t/t/t<tree text=/"Loaded Item 4.2.1/">/n" +
"/t/t/t/t<tree text=/"Loaded Item 4.2.1.2/"/>/n" +
"/t/t/t/t<tree text=/"Loaded Item 4.2.1.3/"/>/n" +
"/t/t/t</tree>/n" +
"/t/t/t<tree text=/"Loaded Item 4.2.2/"/>/n" +
"/t/t</tree>/n" +
"/t</tree>/n" +
"/t<tree text=/"WebFX Home/" action=/"http://webfx.eae.net/"/n" +
"/t/ticon=/"/n">http://webfx.eae.net/images/favicon.gif/"/>/n" +
"</tree>");
%>
tree2.xml <?xml version="1.0"?>
<tree>
<tree text="Loaded File 2 Item 1" action="javascript:alert(1)" />
<tree text="Loaded File 2 Item 2" action="javascript:alert(2)">
<tree text="Loaded File 2 Item 2.1" action="javascript:alert(2.1)" />
<tree text="Loaded File 2 Item 2.2 (LOOP)" src="tree1.xml" action="javascript:alert(2.1)" />
</tree>
<tree text="Loaded File 2 Item 3" action="javascript:alert(3)" />
</tree>
tree2.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Loaded File 2 Item 1/" action=/"javascript:alert(1)/" />/n" +
"/t<tree text=/"Loaded File 2 Item 2/" action=/"javascript:alert(2)/">/n" +
"/t/t<tree text=/"Loaded File 2 Item 2.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t/t<tree text=/"Loaded File 2 Item 2.2 (LOOP)/" src=/"tree1.jsp/" action=/"javascript:alert(2.1)/" />/n" +
"/t</tree>/n" +
"/t<tree text=/"Loaded File 2 Item 3/" action=/"javascript:alert(3)/" />/n" +
"</tree>");
%>
emptytree.xml <?xml version="1.0"?>
<tree/>
emptytree.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"<tree/>");
%>
这样就能够正确的显示树图了,这种方法比较适合动态的通过程序获取树图。
还有种比较彻底的办法,更改xloadtree关于xmlhttp的部分。
将xloadtree的Demo直接放置到Tomcat的Webapps目录下,不能正确显示,总显示“Error Load tree.xml”,一步步对问题进行了跟踪,找到了问题的所在。问题在于XmlHttp使用了responseXML,返回的消息必须是xml,更准确的说是必须能够被识别为xml,要做到这点其实很简单,只要设置ContentType="test/xml"。
我的做法是对xml用jsp进行了包装:
tree.xml <?xml version="1.0" encoding="UTF-8"?>
<tree>
<tree text="Load "tree1.xml"" src="tree1.xml" />
<tree text="Loaded Item 1" action="http://webfx.eae.net" />
<tree text="Loaded Item 2">
<tree text="Loaded Item 2.1" action="javascript:alert(2.1)" />
</tree>
<tree text="Loaded Item 3 (with target)" action="http://www.google.com" target="_new" />
<tree text="Load "tree1.xml"" src="tree1.xml" />
</tree>
tree.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Load "tree1.xml"/" src=/"tree1.jsp/" />/n" +
"/t<tree text=/"Loaded Item 1/" action=/"http://webfx.eae.net/" />/n" +
"/t<tree text=/"Loaded Item 2/">/n" +
"/t/t<tree text=/"Loaded Item 2.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t</tree>/n" +
"/t<tree text=/"Loaded Item 3 (with target)/" action=/"http://www.google.com/" target=/"_new/" />/n" +
"/t<tree text=/"Load "tree1.xml"/" src=/"tree1.jsp/" />/n" +
"</tree>");
%>
tree1.xml <?xml version="1.0"?>
<tree>
<tree text="Loads tree2.xml" src="tree2.xml"/>
<tree text="Loads NOT_AVAILABLE.xml" src="NOT_AVAILABLE.xml"
icon="images/xp/folder.png"/>
<tree text="Loads emptytree.xml" src="emptytree.xml"
icon="images/xp/folder.png"/>
<tree text="Loaded Item 3" action="javascript:alert(3)" />
<tree text="Loaded Item 4" action="javascript:alert(4)">
<tree text="Loaded Item 4.1" action="javascript:alert(2.1)" />
<tree text="Loaded Item 4.2">
<tree text="Loaded Item 4.2.1">
<tree text="Loaded Item 4.2.1.2"/>
<tree text="Loaded Item 4.2.1.3"/>
</tree>
<tree text="Loaded Item 4.2.2"/>
</tree>
</tree>
<tree text="WebFX Home" action="http://webfx.eae.net"
icon="http://webfx.eae.net/images/favicon.gif"/>
</tree>
tree1.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Loads tree2.xml/" src=/"tree2.jsp/"/>/n" +
"/t<tree text=/"Loads NOT_AVAILABLE.xml/" src=/"NOT_AVAILABLE.xml/"/n" +
"/t/ticon=/"images/xp/folder.png/"/>/n" +
"/t<tree text=/"Loads emptytree.xml/" src=/"emptytree.jsp/"/n" +
"/t/ticon=/"images/xp/folder.png/"/>/n" +
"/t<tree text=/"Loaded Item 3/" action=/"javascript:alert(3)/" />/n" +
"/t<tree text=/"Loaded Item 4/" action=/"javascript:alert(4)/">/n" +
"/t/t<tree text=/"Loaded Item 4.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t/t<tree text=/"Loaded Item 4.2/">/n" +
"/t/t/t<tree text=/"Loaded Item 4.2.1/">/n" +
"/t/t/t/t<tree text=/"Loaded Item 4.2.1.2/"/>/n" +
"/t/t/t/t<tree text=/"Loaded Item 4.2.1.3/"/>/n" +
"/t/t/t</tree>/n" +
"/t/t/t<tree text=/"Loaded Item 4.2.2/"/>/n" +
"/t/t</tree>/n" +
"/t</tree>/n" +
"/t<tree text=/"WebFX Home/" action=/"http://webfx.eae.net/"/n" +
"/t/ticon=/"/n">http://webfx.eae.net/images/favicon.gif/"/>/n" +
"</tree>");
%>
tree2.xml <?xml version="1.0"?>
<tree>
<tree text="Loaded File 2 Item 1" action="javascript:alert(1)" />
<tree text="Loaded File 2 Item 2" action="javascript:alert(2)">
<tree text="Loaded File 2 Item 2.1" action="javascript:alert(2.1)" />
<tree text="Loaded File 2 Item 2.2 (LOOP)" src="tree1.xml" action="javascript:alert(2.1)" />
</tree>
<tree text="Loaded File 2 Item 3" action="javascript:alert(3)" />
</tree>
tree2.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"/n" +
"<tree>/n" +
"/t<tree text=/"Loaded File 2 Item 1/" action=/"javascript:alert(1)/" />/n" +
"/t<tree text=/"Loaded File 2 Item 2/" action=/"javascript:alert(2)/">/n" +
"/t/t<tree text=/"Loaded File 2 Item 2.1/" action=/"javascript:alert(2.1)/" />/n" +
"/t/t<tree text=/"Loaded File 2 Item 2.2 (LOOP)/" src=/"tree1.jsp/" action=/"javascript:alert(2.1)/" />/n" +
"/t</tree>/n" +
"/t<tree text=/"Loaded File 2 Item 3/" action=/"javascript:alert(3)/" />/n" +
"</tree>");
%>
emptytree.xml <?xml version="1.0"?>
<tree/>
emptytree.jsp <%
response.setContentType("text/xml");
out.println("<?xml version=/"1.0/"?>/n" +
"<tree/>");
%>
这样就能够正确的显示树图了,这种方法比较适合动态的通过程序获取树图。
还有种比较彻底的办法,更改xloadtree关于xmlhttp的部分。
相关文章推荐
- 今天使用xloadtree遇到了问题:(
- xloadtree使用过程中的相关问题
- Android中使用unix本地套接字编程 编译问题
- ireport $P{SUBREPORT_DIR}参数的使用 解决:Could not load object from location 不能加载子报表问题
- 使用安装在linux端的loadgenerator,在controller加载并发人数受限的问题解决
- 使用开源imageLoader优化listview加载大量本地图片的demo
- 使用WKWebView的一个问题:iOS中使用本地html的一个大坑
- EXTJS4.0 tree.Panel 使用了model 取值 问题
- 解决Centos 6使用svn时本地使用明文密码的问题,保存密文密码
- 使用SharedObject缓存游戏框架到本地和版本更新的demo
- neo4j load csv 的使用问题总结
- 【iOS开发问题】使用NSCoding写入本地文件读取不出来或者文件没有写入本地
- phpmyadmin使用load语句导入.dat数据中文乱码问题解决
- 新浪微盘之一个api的使用问题---看别人demo怎么写(现成的)
- c# -- 解决vs使用本地iis运行项目支持局域网访问的问题(附防火墙端口开放步骤)
- 使用libxml提示libxml/tree.h找不到的问题解决
- Adapter Adapter.notifyDataSetChanged()使用时容易出现的问题 跑马灯效果Demo
- centos中使用tree和you need to be root to this command问题
- DB2数据库在使用load命令导入问题
- zencart 本地环境使用ip访问无法登陆的问题