---
title: "Struts2使用<s:tree>标签显示无限树形菜单"
author: "minfirefox"
date: "2008-11-19T14:20:53Z"
tags: []
categories: ["企业架构"]
slug: "struts2-s-tree"
draft: false
lastmod: "2008-11-19T17:00:10Z"
id: 270299
url: "https://minfirefox.iteye.com/blog/270299"
---

<span style="color:red">级联显示无限树形菜单</span>
效果图：
![](/upload/attachment/51207/ea7cb6f7-e3a3-3581-8047-e39a36caede0.png)


实体类Node：

```java

public class Node implements java.io.Serializable {
	
	private Integer id;
	//父节点
	private Node parentNode = null;
	//所有子节点
	private Set<Node> childrenSet = new TreeSet<Node>();

	private String name = "";

	//其它属性
	//getXxx()、setXxx()
}

```



JSP页面中使用<s:tree>标签显示，其中：
rootNode表示Action中的传递的根节点，
childCollectionProperty表示node下所有子节点，
nodeIdProperty表示根节点的id。

```jsp

<s:tree id="treeTestId" theme="ajax" rootNode="node" 
	templateCssPath="treenode.css"
	childCollectionProperty="childrenSet" nodeIdProperty="id"
	nodeTitleProperty="'<a href=manage.action?id='+id+' target=main>'+name +'</a>'"
	treeSelectedTopic="treeSelected"
	showRootGrid="false" showGrid="true">
</s:tree>

```



数据库中：
![](/upload/attachment/51215/185ddcfe-09ae-3d8e-818d-d77a02bef8e8.png)