主题:新手学JSP 遇见个问题,很多人都说搞不定
我想使dtree的这段代码
<script language=javascript>
var d = new dTree('d');
d.add(0,-1,'DMSERVER','return false;');
d.add(1,0,'Cabinets',"");
d.add(2,1,"Folders","");
var index = 2;
for(var i = 0; i < '<%=dd%>'.split(',').length-1; i++) {
d.add(++index, 1,'<%=dd%>'.split(',')[i], '');
}
的'<%=dd%>'.split(',')[i]与form这段代码<%
String[] cabinet = dd.split(",");
for (int i = 0; i < cabinet.length; i++) {
out.print("<a href=\"#\" onClick=\"findFolders('" + cabinet[i]
+ "');\" >");
out.print(cabinet[i]);
out.print("</a>");
out.print("
");
}
%>中的cabinet[i]的超链接完全对应(即点击'<%=dd%>'.split(',')[0]与cabinet[0]效果一样....等等)
代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html>
<head>
<title></title>
<link href="<%=request.getContextPath() %>/dtree/dtree.css" type="text/css" rel="stylesheet">
<script src="<%=request.getContextPath() %>/dtree/dtree.js" type="text/javascript"></script>
<%String dd = (String) session.getAttribute("dd");
String cabinetName = (String) session.getAttribute("cabinetName");
String ee = (String) session.getAttribute("ee");
String ff = (String) session.getAttribute("ff");%>
<script language=javascript>
var d = new dTree('d');
d.add(0,-1,'DMSERVER','return false;');
d.add(1,0,'Cabinets',"");
d.add(2,1,"Folders","");
var index = 2;
for(var i = 0; i < '<%=dd%>'.split(',').length-1; i++) {
d.add(++index, 1,'<%=dd%>'.split(',')[i], '');
}
function findFolders(cabinetName){
myForm.action="<%=basePath%>ShowFolders?cabinetName="+cabinetName;
myForm.submit();
}
function findDoc(folderName,cabinetName){
myForm.action="<%=basePath%>ShowDoc?folderName="+folderName+"&cabinetName="+cabinetName;
myForm.submit();
}
</script>
</head>
<body>
<form method="post" name="myForm">
<table>
<tr>
<td>
Cabinets:
<%
String[] cabinet = dd.split(",");
for (int i = 0; i < cabinet.length; i++) {
out.print("<a href=\"#\" onClick=\"findFolders('" + cabinet[i]
+ "');\" >");
out.print(cabinet[i]);
out.print("</a>");
out.print("
");
}
%>
Folders:
<%
if(ee!=null){
String[] folders = ee.split(",");
for (int i = 0; i < folders.length; i++) {
out.print("<a href=\"#\" onClick=\"findDoc('"+folders[i]+"','"+cabinetName
+"');\" >");
out.print(folders[i]);
out.print("</a>");
out.print("
");
}
}%>
Documentum:
<%
if(null!=ff){
String[] doc = ff.split(",");
for(int i=0; i < doc.length; i++){
out.print(doc[i]);
out.print("
");
}
}
%>
</td>
</tr>
</table>
</form>
<table width="98%" cellpadding="2" cellspacing="0" height="100%" align="center">
<tr valign="top">
<td width="40%" style="border-right: 1px solid #bbb;">
<script>
document.write(d);
</script>
</td>
</tr>
</table>
</body>
</html>
<script language=javascript>
var d = new dTree('d');
d.add(0,-1,'DMSERVER','return false;');
d.add(1,0,'Cabinets',"");
d.add(2,1,"Folders","");
var index = 2;
for(var i = 0; i < '<%=dd%>'.split(',').length-1; i++) {
d.add(++index, 1,'<%=dd%>'.split(',')[i], '');
}
的'<%=dd%>'.split(',')[i]与form这段代码<%
String[] cabinet = dd.split(",");
for (int i = 0; i < cabinet.length; i++) {
out.print("<a href=\"#\" onClick=\"findFolders('" + cabinet[i]
+ "');\" >");
out.print(cabinet[i]);
out.print("</a>");
out.print("
");
}
%>中的cabinet[i]的超链接完全对应(即点击'<%=dd%>'.split(',')[0]与cabinet[0]效果一样....等等)
代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html>
<head>
<title></title>
<link href="<%=request.getContextPath() %>/dtree/dtree.css" type="text/css" rel="stylesheet">
<script src="<%=request.getContextPath() %>/dtree/dtree.js" type="text/javascript"></script>
<%String dd = (String) session.getAttribute("dd");
String cabinetName = (String) session.getAttribute("cabinetName");
String ee = (String) session.getAttribute("ee");
String ff = (String) session.getAttribute("ff");%>
<script language=javascript>
var d = new dTree('d');
d.add(0,-1,'DMSERVER','return false;');
d.add(1,0,'Cabinets',"");
d.add(2,1,"Folders","");
var index = 2;
for(var i = 0; i < '<%=dd%>'.split(',').length-1; i++) {
d.add(++index, 1,'<%=dd%>'.split(',')[i], '');
}
function findFolders(cabinetName){
myForm.action="<%=basePath%>ShowFolders?cabinetName="+cabinetName;
myForm.submit();
}
function findDoc(folderName,cabinetName){
myForm.action="<%=basePath%>ShowDoc?folderName="+folderName+"&cabinetName="+cabinetName;
myForm.submit();
}
</script>
</head>
<body>
<form method="post" name="myForm">
<table>
<tr>
<td>
Cabinets:
<%
String[] cabinet = dd.split(",");
for (int i = 0; i < cabinet.length; i++) {
out.print("<a href=\"#\" onClick=\"findFolders('" + cabinet[i]
+ "');\" >");
out.print(cabinet[i]);
out.print("</a>");
out.print("
");
}
%>
Folders:
<%
if(ee!=null){
String[] folders = ee.split(",");
for (int i = 0; i < folders.length; i++) {
out.print("<a href=\"#\" onClick=\"findDoc('"+folders[i]+"','"+cabinetName
+"');\" >");
out.print(folders[i]);
out.print("</a>");
out.print("
");
}
}%>
Documentum:
<%
if(null!=ff){
String[] doc = ff.split(",");
for(int i=0; i < doc.length; i++){
out.print(doc[i]);
out.print("
");
}
}
%>
</td>
</tr>
</table>
</form>
<table width="98%" cellpadding="2" cellspacing="0" height="100%" align="center">
<tr valign="top">
<td width="40%" style="border-right: 1px solid #bbb;">
<script>
document.write(d);
</script>
</td>
</tr>
</table>
</body>
</html>