tree.jsp集结

本文介绍了一种使用JSP和JavaScript实现动态树形菜单的方法。通过`jsp:useBean`指令初始化一个`RSReturnTree`对象,该对象从数据库中查询菜单数据并构建树结构。页面加载时调用`getMenu1`方法生成菜单,每个菜单项包含链接及图标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用法简介:

页面处理:
<jsp:useBean id="tree" class="com.hhsoft.houtai.RSReturnTree" />



<body>
<div class="dtree" style="width: 100%; height: 95%; overflow:auto">
<script type="text/javascript" src="js/tree.js"></script>
<script type="text/javascript">
<%=tree.getMenu1("T_tree")%>
document.write(d);

function openLocation(strUrl)
{
parent.frames[2].location.replace(strUrl)

}
function cwin()
{if(parent.testframeset.cols!='200,*')
{parent.testframeset.cols='200,*';
}
else{parent.testframeset.cols='-10,*';
}}
</script>
</div>
</body>


类中的处理:
package com.hhsoft.houtai;
import com.hhsoft.database.db;
import com.sun.rowset.CachedRowSetImpl;
public class RSReturnTree {
db dd=new db();

String menu="d = new dTree('d');\n d.add('001',-1,'后台维护列表');\n";
public String getMenu1(String SQL){
CachedRowSetImpl crs=null;
crs=dd.dbquery("select * from "+SQL+"","2008");
System.out.println("select * from "+SQL+"");
//不用再建立新的返回树的类,只需要把数据库的字段名相同就OK了,数据库名称为变量
try{
int bh=0;
while(crs.next()){
String mc=new String(crs.getString("mc"));
//System.out.println("111111111111111111");
String clj=new String(crs.getString("url"));
//System.out.println("11111122222221111111");
System.out.println(mc+"*******"+clj);
String img="";//new String(crs.getString("image"));
menu+="d.add('"+bh+"','001','"+mc+"','"+clj+"','','','img/page.gif','','');\n";
bh++;
}

}catch(Exception e){
System.out.println("~~~~~getMenu1~返回时有异常~~~~~~~~");
}

return menu;
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值