struts2简单实现树形菜单(不连数据库,静态在页面完成)

想要从数据库动态获取的,可以看我的另一篇关于树形菜单的struts2实现,这里只介绍在页面用标签静态完成的菜单

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Struts 2 AJAX - Tree</title>
        <s:head theme="ajax" debug="true" />
        <script type="text/javascript">
            function treeNodeSelected(arg) {
                alert("id["+arg.source.widgetId+"], name["+ arg.source.title+ "] selected");
            }
            dojo.addOnLoad(function() {               
                var s = dojo.widget.byId('parentId').selector;               
                dojo.event.connect(s, 'select', 'treeNodeSelected');
            });
        </script>
    </head>
    <body>
        <h2>
            Tree
        </h2>
        <div style="float:left; margin-right: 50px;">
            <s:tree label="parent" id="parentId" theme="ajax"
                templateCssPath="/struts/tree.css" showRootGrid="true"
                showGrid="true">
                <s:treenode theme="ajax" label="child1" id="child1Id">
                    <s:treenode theme="ajax" label="grandchild1" id="grandchild1Id" />
                    <s:treenode theme="ajax" label="grandchild2" id="grandchild2Id" />
                    <s:treenode theme="ajax" label="grandchild3" id="grandchild3Id" />
                    <s:treenode label="tree4" theme="ajax" id="tree4">
                    <s:treenode label="tree5" theme="ajax" id="tree5"></s:treenode>
                    </s:treenode>
                </s:treenode>
                <s:treenode theme="ajax" label="child2" id="child2Id" />
                <s:treenode theme="ajax" label="child3" id="child3Id" />
                <s:treenode theme="ajax" label="child4" id="child4Id" />
                <s:treenode theme="ajax" label="child5" id="child5Id">
                    <s:treenode theme="ajax" label="gChild1" id="gChild1Id" />
                    <s:treenode theme="ajax" label="gChild2" id="gChild2Id" />
                </s:treenode>
            </s:tree>
        </div>
    </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值