我打算用dtree写一个树状结构,结构树状结构怎么也显示不出来。
工程的目录结构是这样的我把example01.html文件中的内容拷贝到index.jsp文件中,代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head>
<title>Destroydrop » Javascripts » Tree</title>
<!--head中的绝大多数内容都不会呈现在网页中 --> <link rel="StyleSheet" href="../styles/dtree.css" type="text/css" />
<script type="text/javascript" src="../scripts/dtree.js"></script></head><body><h1><a href="/">Destroydrop</a> » <a href="/javascripts/">Javascripts</a> » <a href="/javascripts/tree/">Tree</a></h1><h2>Example</h2><div class="dtree"> <p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p> <script type="text/javascript">
document.write("df");//这是我测试用的,放在这里页面上会显示df,放在d=new dTree('d')后面页面就没有df了。
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','../img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','../img/trash.gif');
document.write(d);
</script></div></body></html>
运行之后是这样的:树根本没有显示出来
工程的目录结构是这样的我把example01.html文件中的内容拷贝到index.jsp文件中,代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head>
<title>Destroydrop » Javascripts » Tree</title>
<!--head中的绝大多数内容都不会呈现在网页中 --> <link rel="StyleSheet" href="../styles/dtree.css" type="text/css" />
<script type="text/javascript" src="../scripts/dtree.js"></script></head><body><h1><a href="/">Destroydrop</a> » <a href="/javascripts/">Javascripts</a> » <a href="/javascripts/tree/">Tree</a></h1><h2>Example</h2><div class="dtree"> <p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p> <script type="text/javascript">
document.write("df");//这是我测试用的,放在这里页面上会显示df,放在d=new dTree('d')后面页面就没有df了。
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','../img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','../img/trash.gif');
document.write(d);
</script></div></body></html>
运行之后是这样的:树根本没有显示出来
解决方案 »
- JSTL问题!!!!急急急!!!!!!!!!
- 连接数据库时出现的问题
- 网页安全
- java、jsp、tomcat跟.properties文件什么关系?为什么以前没有听说过,接触struts之后突然出现这么多properties文件?
- 页面验证图片重复加载问题?
- 有没有什么类,把普通字符串中的‘<’,‘>’等字符转换成xml字符?
- 有谁使用过jspwiki架站吗?
- 有关Jbuilder的事
- 关于Statement
- 哪里有下载eclipse的插件?最全的!
- 听说标题要长长长长长长长长长长长长长长长长长长长长,才有人回复
- jsp cookie 保存密码 用浏览器清除cookie 后再刷新发先cookie不空
MzTreeView 1.0 树形控件 Demo 这个树的节点有1000多个 但速度很快 使用:
1.下载控件,MzTreeView10
2.把MzTreeView10整个目录放置在web工程下(图片,js)
3.在后台建一个 java类(生成字符串返回给前台)
格式如下: tree.nodes["408_1239"]=" text:显示文本; data:id=自己的ID;URL=转向的URl method:alert('');"; !注意分号和 “”号也都要,自己写方法取得数据库要生存树的表所有记录,然后拼凑,一条记录生成一个这样的节点字符串给JS解析 tree是可以指定的树的名称
408 是数据库的父节点id
1239 是自己的id
text 是显示在页面的节点名称
data 跟URL 配和,当点击转向另外地址是 后面自动带参数id=自己的ID;如url.jsp?id=5;
mehod 点击后触发的js方法,可自定义执行 默认解析根节点为0(数据库要设置)后台String sqlStr = "select id,parent_id, name from xx where parent_id is not null order by parent_id ";
try {
HibernateDao.getSession().beginTransaction();
conn = HibernateDao.getSession().connection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlStr);
while ( rs.next()) {
s+="tree.nodes['"+rs.getString("parent_id")+"_"+rs.getString("id")+"'] = 'text:"+rs.getString("name")+";method:myfunc(\""+rs.getString("name")+','+rs.getString("id")+"\")';";
}
System.out.println(s);
conn.commit(); }
catch( SQLException e)
{ e.printStackTrace(); }
finally{
try{ if( stmt != null )
stmt.close();
if( rs != null )
rs.close();
if( conn != null )
conn.close();
}catch( SQLException e)
{
e.printStackTrace();
}
}JSP页面代码<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="util.*,java.util.*,com.feiji.dto.SysMenuDto,org.dom4j.Document;"%>
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <SCRIPT type="text/javascript" src="<%=basePath %>js/test.js"></SCRIPT>
<SCRIPT type="text/javascript" src="<%=basePath %>js/MzTreeView10.js"></SCRIPT>
<link rel="stylesheet" href="images/total.css" type="text/css">
<style type="text/css">
body, td { font-family: 宋体; font-size: 12px; }
A:LINK, A:VISITED, A:ACTIVE, A:HOVER { color:#000; text-decoration:none; font-family:arial; font-size:12px; padding-left:2px; }
</style>
<title>文件</title>
</head>
<body class="body01">
<table width="100%" border=0 cellspacing=3 bgcolor="#B8D1F8">
<tr>
<td bgcolor=white valign=top>
<div id=treeviewarea style="background-color: "></div>
<SCRIPT LANGUAGE="JavaScript">
<!-- var tree = new MzTreeView("tree");
tree.setIconPath("/elearn/course/treeImages/");
tree.nodes['0_1'] = 'text:课程目录1';
<% String tree = (String)request.getAttribute("treeList"); out.print(tree); %>
document.getElementById('treeviewarea').innerHTML = tree.toString();
function myfunc(n){
window.returnValue= n;
window.close();
} //-->
</SCRIPT>
</tr>
</table>
</body>
</html>