EasyUI Tree
TreeObj
public class TreeObj { private String name; private String url; private List<TreeObj> children = new ArrayList<TreeObj>(); }
tree.jsp
<li><c:if test="${not empty tree.url}"> <a href="javascript:void(0);" onclick="menuClick('${tree.url}')"> <span>${tree.name}</span></a> </c:if> <c:if test="${empty tree.url}"> <span>${tree.name}</span> </c:if> <c:if test="${not empty tree.children}"> <ul> <c:forEach var="tree" items="${tree.children}"> <c:set var="tree" value="${tree}" scope="request" /> <jsp:include page="tree.jsp" /> </c:forEach> </ul> </c:if></li>
main.jsp
<div class="easyui-panel" style="padding: 5px"> <ul id="easyui_tree" class="easyui-tree" data-options=" animate: true, onContextMenu: function(e,node){ e.preventDefault(); $(this).tree('select',node.target); $('#easyui_tree_menu').menu('show',{ left: e.pageX, top: e.pageY }); } "> <!-- 树按钮 --> <c:import url="../tree.jsp"></c:import> </ul> </div> <div id="easyui_tree_menu" class="easyui-menu" style="width: 120px;"> <div onclick="append()" data-options="iconCls:'icon-add'">新增</div> <div onclick="removeit()" data-options="iconCls:'icon-remove'">移除</div> <div class="menu-sep"></div> <div onclick="expand()">展开</div> <div onclick="collapse()">收缩</div> </div>