求JSP实现动态目录树

lipeng88888888888888 2009-08-06 09:15:35
求JSP实现动态目录树,技术成熟,导入项目后就能用,至少要有 .jsp .js .java 如果有测试数据还要有数据库文件,在线等急用,先谢过啦
...全文
197 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
留个邮箱吧85060839@qq.com,测试通过马上给分
xinyung 2009-08-06
  • 打赏
  • 举报
回复
**分成?
jypapgl 2009-08-06
  • 打赏
  • 举报
回复
给钱最好
lixiaoyan3 2009-08-06
  • 打赏
  • 举报
回复
给你发两个文件,一个是code.html,一个是note.xml。在note.xml文件中配置了要显示的内容即可。
拿来直接可以用的。
code.html代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>XML+JS=treeMenu</title>
<style type="text/css">
*{
padding:0px;
margin:0px;
}
a{
text-decoration:none;
}
img{
border:none;
}
ul{
list-style:none;
}
#menu{
font-size:12px;
}
.cls_a{
text-decoration:none;
color:black;
padding:2px;
}
.cls_a:hover{
padding-left:4px;
border-bottom:1px dotted purple;
color:purple;
}
.cls_parent{

}
.cls_parent .cls_icon{
position:relative;
top:5px;
margin-right:2px;
}
.cls_parent .cls_check{
position:relative;
top:2px;
margin-right:2px;
}
.cls_parent ul{
margin-left:42px;
}
.cls_child{

}
</style>
<script type="text/javascript">
function xmlTree(pPath,mPath){
this.plusImgPath=pPath;
this.minusImgPath=mPath;
}
xmlTree.prototype.loadXMLDoc=function(xml_file){

var xmlDoc;
try{//IE
//创建空的微软 XML 文档对象
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}catch(e){
try{//FF
//创建空的 XML 文档对象
xmlDoc=document.implementation.createDocument("","",null);
}catch(e){
alert(e.message);
}
}

try{
//关闭异步加载,这样可确保在文档完整加载之前,解析器不会继续执行脚本
xmlDoc.async=false;
//加载XML文档
xmlDoc.load(xml_file);
}catch(e){
alert(e.message);
return false;
}
return xmlDoc;
}
var str="";
xmlTree.prototype.treeShow=function(xml_file){
var xmlDoc=this.loadXMLDoc(xml_file);
var root=xmlDoc.documentElement;
str="<ul>";
this.getTreeNodes(root);
str+="</ul>";
document.getElementById("menu").innerHTML=str;
}
xmlTree.prototype.getTreeNodes=function(root){
if(root!=null){
for(var i=0;i<root.childNodes.length;i++){
var node=root.childNodes[i];

/*Firefox,以及其他一些浏览器,会把空的空白或换行作为文本节点来处理,而 Internet Explorer 不会这样.所以为了兼容大部分浏览器,需要检查节点类型.元素节点的类型是1*/
if(node.nodeType==1){
var name=node.getAttribute("name");

/*var name=node.getAttribute("name")和var name=node.attributes.getNamedItem("name").nodeValue等效.*/
if(document.all){
if(node.hasChildNodes){
var id=node.getAttribute("id");
str+="<li id='parent"+id+"' class=\"cls_parent\"><span class='cls_icon'><a href='#' onclick=\"showChildNodes('child"+id+"','img"+id+"','parent"+id+"')\"><img id='img"+id+"' src='"+this.minusImgPath+"' width='18' height='18' /></a></span><span class='cls_check'><input type='checkbox' onclick=\"selectAllChildNodes(this,'child"+id+"')\" /></span><a href='#' class='cls_a'>"+name+"</a><ul id='child"+id+"'>";
this.getTreeNodes(node);
str+="</ul></li>";
//document.write(str);
}else{
str+="<li class=\"cls_child\"><span class='cls_check'><input type='checkbox' /></span><a href='#' class='cls_a'>"+name+"</a></li>";
}
}else{
if(node.hasChildNodes&&node.childNodes.length>1){
var id=node.getAttribute("id");
document.write("id2="+id);
str+="<li id='parent"+id+"' class=\"cls_parent\"><span class='cls_icon'><a href='#' onclick=\"showChildNodes('child"+id+"','img"+id+"','parent"+id+"')\"><img id='img"+id+"' src='"+this.minusImgPath+"' width='18' height='18' /></a></span><span class='cls_check'><input type='checkbox' onclick=\"selectAllChildNodes(this,'child"+id+"')\" /></span><a href='#' class='cls_a'>"+name+"</a><ul id='child"+id+"'>";
document.write(str);
this.getTreeNodes(node);
str+="</ul></li>";
}else{
str+="<li class=\"cls_child\"><span class='cls_check'><input type='checkbox' /></span><a href='#' class='cls_a'>"+name+"</a></li>";
}
}
}
}
}
}
function showChildNodes(obj,img,li_parent){
var oLi=document.getElementById(li_parent);
var aUls=oLi.getElementsByTagName("ul");
var aImgs=oLi.getElementsByTagName("img");
var oDiv=document.getElementById(obj);
var oImg=document.getElementById(img);
if(document.all){//-----------------取得IE下当前样式----------------------
if(oDiv.style["display"]){
var vDisplay=oDiv.style["display"];
}else if(oDiv.currentStyle["display"]){
var vDisplay=oDiv.currentStyle["display"];
}
}else{//-----------------取得FF下当前样式----------------------
var vDisplay=document.defaultView.getComputedStyle(oDiv,null).display;
}
if(vDisplay=="block"){
if(aUls.length>0){
for(var i=0;i<aUls.length;i++){
aUls[i].style.display="none";
aImgs[i].src=plusImg;
}
}
oDiv.style.display="none";
oImg.src=plusImg;
}else{
oDiv.style.display="block";
oImg.src=minusImg;
}
}
function selectAllChildNodes(thisObj,obj){
var obj=document.getElementById(obj);
var aChildNodes=obj.getElementsByTagName("input");
if(thisObj.checked){
for(var i=0;i<aChildNodes.length;i++){
aChildNodes[i].checked=true;
}
}else{
for(var i=0;i<aChildNodes.length;i++){
aChildNodes[i].checked=false;
}
}
}
</script>
</head>
<body>
<div style="margin:40px auto; width:500px; padding:12px;" id="menu">
</div>
<script type="text/javascript">
var plusImg="add.jpg";
var minusImg="add1.jpg";
var myMenu=new xmlTree(plusImg,minusImg);
myMenu.treeShow("note.xml");
showChildNodes("child1000","img1000","parent1000");

</script>
</body>
</html>
note.xml文件代码如下:
<?xml version="1.0" encoding="gb2312"?>
<root>
<start name="all process" id="1000">
<folder name="谷歌金山词霸合作版" id="1100">
<process name="插件管理器" id="1110">
<ddd name="11111111" id="1111"></ddd>
<ddd name="22222222" id="1112"></ddd>
</process>
<process name="谷歌金山词霸合作版" id="1200"></process>
<process name="迷你背单词" id="1210"></process>
<process name="生词本" id="1220"></process>
<process name="卸载程序" id="1230"></process>
</folder>
<folder name="清华同知网" id="1300">
<process name="CAJViewer 7.0" id="1310"></process>
<process name="个人数字图书馆2.0" id="1320"></process>
<process name="卸载CAJViewer 7.0" id="1330"></process>
</folder>
<folder name="360安全卫士" id="1400">
<process name="360安全卫士" id="1410"></process>
<process name="管理应用软件" id="1420"></process>
<process name="卸载360安全卫士" id="1430"></process>
<process name="修复360安全卫士" id="1440"></process>
<process name="修复系统漏洞" id="5"></process>
</folder>
<folder name="中国移动飞信" id="1500">
<process name="Fetion 2008" id="1510"> </process>
<process name="帮助" id="1520"></process>
<process name="卸载" id="1530"></process>
</folder>
<folder name="Microsoft Office" id="1600">
<process name="Microsoft Office Access 2003" id="1610"></process>
<process name="Microsoft Office Excel 2003" id="1620"></process>
<process name="Microsoft Offcie PowerPoint 2003" id="1630"></process>
<process name="Microsoft Office Word 2003" id="1640"></process>
</folder>
<folder name="谷歌浏览器" id="1700">
<process name="谷歌浏览器" id="1710"></process>
<process name="卸载谷歌浏览器" id="1720"></process>
</folder>
</start>
</root>
javagxc 2009-08-06
  • 打赏
  • 举报
回复
JavaScript实现的目录树源码http://download.csdn.net/source/1478786
robyjeffding 2009-08-06
  • 打赏
  • 举报
回复
主要下个树控件就可以了,比如DTree,网上有很多这样的控件,用起来也比较方便,楼上还是去网上搜搜吧,自己动手,丰衣足食!

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧