<%@ page contentType="text/html; charset=gb
<html>
<head>
<title></title>
<meta http
<script language="JavaScript">
<!
function MM_goToURL() { //v
var i
for (i=
}
//
</script>
<link href="css/ip
</head>
<body topmargin = "
<table border="
<tr><td>
</td>
</tr>
<tr valign="top">
<td height="
<span id="view"></span>
</td>
</tr>
<tr valign="bottom">
<td> </td>
</tr>
</table>
<div align="right"></div>
</body>
<script>
/**
* 構造樹
*/
function isbrother()
{
var is=flase;
}
function tree(n) {
var id = new Array("bar"
if(n ==
n =
i =
s = "";
}
s += "<table border=
for(;i<tree_ar
var k = (n >= tree_ar[i+
if(tree_ar[i][
{
id[
}
s += "<tr id=
if(n > tree_ar[i+
s += "</td></tr></table>";
return tree_ar[i+
}
if(n < tree_ar[i+
s += "<tr style=
if(tree_ar[i][
{ //如果有下個兄弟節點
s+="background=
s+="></td><td>";
var m = tree(tree_ar[++i][
s += "</td></tr>";
if(m < n) { // 當遞歸返回值小於當前層次期望值時
s += "</table>";
return m;
}
}
}
s += "</table>";
return s;
}
</script>
<script for=pad event=onclick>
// 分枝節點的點擊響應
v = this
if(v
v
this
view
}else {
v
this
// view
/**
* 以下代碼用於關閉已展開的其他分枝
* 如需自行關閉展開的分枝則從這裡直接返回或刪去這段代碼
*/
if(! tree_ar[this
genTreeInfo(this);
var n =
for(i=n;i<tree_ar
if(tree_ar[i]
tree_ar[i]
tree_ar[i]
}
}
while(tree_ar[
while(
if(tree_ar[n]
tree_ar[n]
tree_ar[n]
/** 記錄層次信息
function genTreeInfo(o) {
var el = o
for(var i=
if(el
tree_ar[el
}
if(el
tree_ar[el
tree_ar[el
}
}
}
</script>
<script for=bar event=onclick>
// 無分枝節點的點擊響應
//view
// 自行修改為參數數組定義的點擊動作
</script>
<script for=bar event=onclick>
// 無分枝節點的點擊響應
//view
</script>
<script>
/**
* 基本參數數組
* 數據可較簡單的由服務器端提供
* 列
* 列
* 列
* 其余自行擴充
*/
tree_ar = new Array(
<%
FileTree tree=new FileTree();
String array=tree
%>
<%=array%>
new Array(
/*** 創建菜單 ***/
menus
</script>
</html>
import java
public class FileTree {
public FileTree() {
/**
*
* 生成文件目錄樹
*
* @param path
* 目錄路徑
* @return 返回jsp 頁面所需的目錄數組(JavaScript 數組)
*
*/
/*
* 有無兄弟節點
*/
private boolean hasNexetBrother = false;
/*
* 節點層次
*/
private int index=
public String showFileTree(String path) {
String s = "";
File dir = new File(path);
if (dir != null && dir
String absolutePath = dir
absolutePath = absolutePath
absolutePath = absolutePath
s += "new Array(" + index + "
+ absolutePath + "\\\\ target=mainFrame>" + dir
+ "</a>
hasNexetBrother = false;
index++;
File[] dirs = dir
java
for (int i =
if (dirs[i]
list
}
}
for (int i =
if (i != list
hasNexetBrother = true;
String dirpath = ((File) list
s += showFileTree(dirpath);//對子文件夾遞歸處理
}
index
return s;
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20339.html