日期:2014-05-17  浏览次数:20711 次

jsp目录树问题急求解
有一个树模型类:
 */
public class ReportNode {

public final static String FOLER_TYPE="FOLER_TYPE";
public final static String PACKAGE_TYPE="PACKAGE_TYPE";
public final static String REPORT_TYPE="REPORT_TYPE";

private String searchPath ;

private String defaultName ;

private String storeID ;

private String reportURL ;

private String nodeType ;

public String getSearchPath() {
return searchPath;
}

public void setSearchPath(String searchPath) {
this.searchPath = searchPath;
}

public String getDefaultName() {
return defaultName;
}

public void setDefaultName(String defaultName) {
this.defaultName = defaultName;
}

public String getStoreID() {
return storeID;
}

public void setStoreID(String storeID) {
this.storeID = storeID;
}

public String getReportURL() {
return reportURL;
}

public void setReportURL(String reportURL) {
this.reportURL = reportURL;
}

public String getNodeType() {
return nodeType;
}

public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}

public List<ReportNode> getChildNodes() {
return childNodes;
}

public void setChildNodes(List<ReportNode> childNodes) {
this.childNodes = childNodes;
}

private List<ReportNode> childNodes ;



}

测试数据类:
public class Test {

  List<ReportNode> list = new ArrayList<ReportNode>() ;
  String restr = "";

public void init(){
ReportNode n1 = new ReportNode();
n1.setDefaultName("aa");
n1.setNodeType("f");
ReportNode n2 = new ReportNode();
n2.setDefaultName("bb");
n2.setNodeType("f");
list.add(n1);
list.add(n2);
ReportNode n3 = new ReportNode();
n3.setDefaultName("cc");
n3.setNodeType("f");
List<ReportNode> list2 = new ArrayList<ReportNode>() ;
list2.add(n3);
ReportNode n4 = new ReportNode();
n4.setDefaultName("dd");
n4.setNodeType("r");
List<ReportNode> list3 = new ArrayList<ReportNode>() ;
list3.add(n4);
n2.setChildNodes(list2);
n3.setChildNodes(list3);

}

 StringBuffer buff = new StringBuffer();
/**
 * 
 * @param rootList
 */
public void buildString(List<ReportNode> rootList){
String str1="";
if(rootList!=null && !rootList.isEmpty()){
Iterator<ReportNode> it = rootList.iterator();
while(it.hasNext()){
ReportNode node = it.next() ;
System.out.println(node.getDefaultName());
if("f".equals(node.getNodeType())){
str1 = "<ul><li>"+node.getDefaultName