JSP + JavaScript 实现类似 MSDN CSDN 导航树效果!

Web 同时被 2 个专栏收录
12 篇文章 0 订阅
11 篇文章 0 订阅

测试站点:
http://www.triaton.com.cn:1080/examples/tree/tree.jsp

类似 MSDN CSDN 导航树效果,JSP + JavaScript 实现! 

<!-- Tree.jsp -->
<%@ page contentType ="text/html;charset=gb2312" %>
<%@ page import="java.util.*;" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<iframe width="100%" height="100" id="hiddenframe"></iframe>
<script>
function ExpandNode(ParentNode,ParentId){
var NodeX = eval(ParentNode.id + '_0');
if (NodeX.style.display == 'none')
 {
  NodeX.style.display="block";
  if (NodeX.loaded == 'no')
     {
      document.frames['hiddenframe'].location.replace("subtree.jsp?PID=" + ParentId + "&PNode=" + ParentNode.id);
      NodeX.loaded = 'yes';
    }
 }
else
 {
  NodeX.style.display='none';
 }
}
</script>
<CENTER>
<TABLE border="1" width="20%" height="60%">
<TR>
<TD>
<DIV style="OVERFLOW: auto;WIDTH: 100%;HEIGHT: 100%">
<TABLE width="300%">
<TR>
<TD>
<%
 java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//  java.sql.Connection ConnectionX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=D://Resin//doc//examples//Tree//tree.mdb","admin", "");
//  java.sql.Statement StatementX = ConnectionX.createStatement();
 java.sql.ResultSet ResultSetX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=e://resin-2.1.6//doc//examples//Tree//tree.mdb","admin", "").createStatement().executeQuery("select *,(select count(*) from tree where parentid = T.id) as children from tree T where parentid = 0");
 int i=0;
 int children;
 int ID;
 while (ResultSetX.next())
       {
children=ResultSetX.getInt("children");
ID=ResultSetX.getInt("id");
%>
<div id='Node_<%= i %>'><a href='#'
        <% if (children >0)
              {%>
                 onClick='ExpandNode(Node_<%= i %>,<%=ID %>)'>+</a>
              <%;}
            else {%>
                >-</a><%;}%>
        <a href='#'
        <% if (children >0)
                {%>
                    onDblClick='ExpandNode(Node_<%= i %>,<%=ID%>)'
                <%}  %>  
                >
                <%=ResultSetX.getString("remark")%></a>
</div>
        
<div id='Node_<%= i %>_0' style='display: none' loaded='no'>
        &nbsp;&nbsp;正在加载 ...
   </div>
 <%
 i++;
 }
 %>
</BODY>
</HTML>

 

<!-- SubTree.jsp -->
<%@ page contentType ="text/html;charset=gb2312" %>
<%@ page import="java.util.*;" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<%
String ParentNode = request.getParameter("PNode");
int i;
int j;
String nSpace="";
j= ParentNode.length()- ParentNode.replaceAll("_","").length();
for (i=0;i<j;i++)
   nSpace = nSpace + "&nbsp;&nbsp;";
String sHTML ="";
i=0;

 java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//  java.sql.Connection ConnectionX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=D://Resin//doc//examples//Tree//tree.mdb","admin", "");
//  java.sql.Statement StatementX = ConnectionX.createStatement();
 java.sql.ResultSet ResultSetX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=e://resin-2.1.6//doc//examples//Tree//tree.mdb","admin", "").createStatement().executeQuery("select *,(select count(*) from tree where parentid =T.id ) as Children from tree T where parentid = " + request.getParameter("PID"));
 int children;
 int ID;
 while (ResultSetX.next())
 {    children=ResultSetX.getInt("children");
      ID=ResultSetX.getInt("id");
      sHTML = sHTML + "<div id='" + ParentNode + "_" + (i + 1) + "'>" + nSpace + "<a href='#'";
  if (children >0)
     sHTML = sHTML + " onClick='ExpandNode(" + ParentNode + "_" + (i + 1) + "," + ID + ")'>+";
  else sHTML = sHTML + ">-";
      sHTML = sHTML + "</a>//n" + "<a href='#'";
  if (children >0)
     sHTML = sHTML + " onDblClick='ExpandNode(" + ParentNode + "_" + (i + 1) + "," + ID + ")'";
  sHTML = sHTML + ">" + ID + ": " + ResultSetX.getString("remark") + "</a></div>";
  if (children >0)
     sHTML = sHTML + "<div id='" + ParentNode + "_" + (i + 1) + "_0' style='display: none' loaded='no'>" + nSpace + "&nbsp;&nbsp;正在加载 ...</div>";
 %>
 <% i++;
    }%>
<BODY>
<script>
   var x = eval('parent.' + '<%= ParentNode + "_0"%>' ) ;
   x.innerHTML="<%= sHTML %>";
</script>
</BODY>
</HTML>

  • 0
    点赞
  • 1
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
相关推荐
<p style="text-align:left;"> <span> </span> </p> <p class="ql-long-24357476" style="font-size:11pt;color:#494949;"> <span style="font-family:"color:#E53333;font-size:14px;background-color:#FFFFFF;line-height:24px;"><span style="line-height:24px;">限时福利1:</span></span><span style="font-family:"color:#3A4151;font-size:14px;background-color:#FFFFFF;">购课进答疑群专享柳峰(刘运强)老师答疑服务。</span> </p> <p> <br /> </p> <p class="ql-long-24357476"> <strong><span style="color:#337FE5;font-size:14px;">为什么说每一个程序员都应该学习MySQL?</span></strong> </p> <p class="ql-long-24357476"> <span style="font-size:14px;">根据《2019-2020年中国开发者调查报告》显示,超83%的开发者都在使用MySQL数据库。</span> </p> <p class="ql-long-24357476"> <img src="https://img-bss.csdn.net/202003301212574051.png" alt="" /> </p> <p class="ql-long-24357476"> <span style="font-size:14px;">使用量大同时,掌握MySQL早已是运维、DBA的必备技能,甚至部分IT开发岗位也要求对数据库使用和原理有深入的了解和掌握。</span><br /> <br /> <span style="font-size:14px;">学习编程,你可能会犹豫选择 C++ 还是 Java;入门数据科学,你可能会纠结于选择 Python 还是 R;但无论如何, MySQL 都是 IT 从业人员不可或缺的技能!</span> </p> <span></span> <p> <br /> </p> <p> <span> </span> </p> <h3 class="ql-long-26664262"> <p style="font-size:12pt;"> <strong class="ql-author-26664262 ql-size-14"><span style="font-size:14px;color:#337FE5;">【课程设计】</span></strong> </p> <p style="font-size:12pt;"> <span style="color:#494949;font-weight:normal;"><br /> </span> </p> <p style="font-size:12pt;"> <span style="color:#494949;font-weight:normal;font-size:14px;">在本课程中,刘运强老师会结合自己十多年来对MySQL的心得体会,通过课程给你分享一条高效的MySQL入门捷径,让学员少走弯路,彻底搞懂MySQL。</span> </p> <p style="font-size:12pt;"> <span style="color:#494949;font-weight:normal;"><br /> </span> </p> <p style="font-size:12pt;"> <span style="font-weight:normal;font-size:14px;">本课程包含3大模块:</span><span style="font-weight:normal;font-size:14px;"> </span> </p> </h3> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <strong class="ql-author-26664262"><span style="font-size:14px;">一、基础篇:</span></strong> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <span class="ql-author-26664262" style="font-size:14px;">主要以最新的MySQL8.0安装为例帮助学员解决安装与配置MySQL的问题,并对MySQL8.0的新特性做一定介绍,为后续的课程展开做好环境部署。</span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <span class="ql-author-26664262" style="font-size:14px;"><br /> </span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <strong class="ql-author-26664262"><span style="font-size:14px;">二、SQL语言篇</span></strong><span class="ql-author-26664262" style="font-size:14px;">:</span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <span class="ql-author-26664262" style="font-size:14px;">本篇主要讲解SQL语言的四大部分数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL,</span><span style="font-size:14px;">学会熟练对库表进行增删改查等必备技能。</span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <span style="font-size:14px;"><br /> </span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <strong class="ql-author-26664262"><span style="font-size:14px;">三、MySQL进阶篇</span></strong><span style="font-size:14px;">:</span> </p> <p class="ql-long-26664262" style="font-size:11pt;color:#494949;"> <span style="font-size:14px;">本篇可以帮助学员更加高效的管理线上的MySQL数据库;具备MySQL的日常运维能力,语句调优、备份恢复等思路。</span> </p> <span><span> <p style="font-size:11pt;color:#494949;"> <span style="font-size:14px;"> </span><img src="https://img-bss.csdn.net/202004220208351273.png" alt="" /> </p> </span></span>
本套餐将包括两个重磅性的课程与一个赠送学习的课程,分别为SpringBoot实战视频教程与RabbitMQ实战教程跟SSM整合开发之poi导入导出Excel。目的是为了让各位小伙伴可以从零基础一步一个脚印学习微服务项目的开发,特别是SpringBoot项目的开发,之后会进入第二个课程:RabbitMQ的实战,即消息中间件在实际项目或者系统中各种业务模块的实战并解决一些常见的典型的问题!核心的知识点分别包括 一、SpringBoot实战历程课程 (1)SpringBoot实战应用场景的介绍与代码实战 (2)发送邮件服务、上传下载文件服务、Poi导入导出Excel (3)单模块与多模块项目构建、项目部署打包、日志、多环境配置、lombok、validator以及mybatis整合实战跟多数据源实战 (4)Redis缓存中间件的实战与缓存雪崩跟缓存穿透等问题的解决实战 (5)RabbitMQ消息中间件在业务模块异步解耦、通信、消息确认机制以及并发量配置等的实战 二、RabbitMQ实战教程课程 (1)RabbitMQ的官网权威技术手册拜读,认识并理解各大专有名词,如队列,交换机,路由,死信队列,消息确认机制等等 (2)RabbitMQ在业务服务模块之间的异步解耦通信实战,如异步记录日志与发送邮件等 (3)商城系统抢单高并发情况下RabbitMQ的限流作用与代码实战 (4)消息确认机制与并发量配置并用来实战商城用户下单 (5)死信队列深入讲解与DLX,DLK,TTL等概念的讲解并用来实战 “支付系统用户下单后支付超时而失效其下单记录”实战 详情,各位小伙伴可以查看两个课程的目录。相信学完该套餐相关课程后,你的实战能力将大大提升!涨薪将不再遥遥无期! 最后,赠送的SSM整合开发之POI导入导出Excel目的是为了让各位小伙伴也可以学习Spring+SpringMVC+Mybatis整合开发的项目,让大家一对比SpringBoot与SPring的项目开发流程以及复杂程度!!! 相信学完之后,你会对SpringBoot爱不释手!!
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页

打赏

playyuer

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值