private void recursiveInsert(Element ele,ArrayList al) throws Exception{
String fatherID=(String)ele.getAttributeValue("orgID");
HashMap hm=new HashMap();
Element e=null;
for(int i=0;i<al.size();i++){
hm=(HashMap)al.get(i);
String fID=(String)hm.get("fatherID");
if(fID!=null)
{
if(fatherID.equalsIgnoreCase(fID)){
e=new Element("TreeNode"); if(hm.get("orgID")!=null){//说明是组织机构
e.setAttribute("orgID",(String)hm.get("orgID"));
e.setAttribute("ClassType","-1");
e.setAttribute("Href","seleOrgUser.do?orgID="+(String)hm.get("orgID"));
e.setAttribute("Title",(String)hm.get("orgName"));
e.setAttribute("NodeXmlSrc","lkp");
e.setAttribute("Target","right");
}
ele.addContent(e);
recursiveInsert(e,al);
}
}
} //for end
}如何把上面的方法变成非递归的?谢谢大家了,急,没分请原谅啊 有了以后补上!
String fatherID=(String)ele.getAttributeValue("orgID");
HashMap hm=new HashMap();
Element e=null;
for(int i=0;i<al.size();i++){
hm=(HashMap)al.get(i);
String fID=(String)hm.get("fatherID");
if(fID!=null)
{
if(fatherID.equalsIgnoreCase(fID)){
e=new Element("TreeNode"); if(hm.get("orgID")!=null){//说明是组织机构
e.setAttribute("orgID",(String)hm.get("orgID"));
e.setAttribute("ClassType","-1");
e.setAttribute("Href","seleOrgUser.do?orgID="+(String)hm.get("orgID"));
e.setAttribute("Title",(String)hm.get("orgName"));
e.setAttribute("NodeXmlSrc","lkp");
e.setAttribute("Target","right");
}
ele.addContent(e);
recursiveInsert(e,al);
}
}
} //for end
}如何把上面的方法变成非递归的?谢谢大家了,急,没分请原谅啊 有了以后补上!
解决方案 »
- 在JSP页面调用struts2标签遇到问题
- 求助:一个运行速度的问题
- 请帮我解释一下,这句代码.
- 向数据库中插入数据
- 数据库兼容问题
- 求救!我做了一个用session对象来保存checkbox复选框的选中值,并在另一个页面中显示的程序,可报错了!请指点一下。
- jsp页面中的框架(Frame)中如何动态显示一个页面啊?(高手指教)
- 请教:mysql中的bigint在jsp程序中如何表示或者转换?
- 向各位請教一個有關console類的問題(設置classpath)
- 地球人都知道JSP可以调用Bean,那么Bean可不可以调用JSP呀?
- 发生Connection reset by peer: socket write error错误,如何解决,在线等......
- dojo 1.1,dijit.layout.TabContainer问题?
public class test{
public static void f(int i){
System.out.println(i);
if(i<0)
return;
f(i-1);
}
public static void g(int i){
while(true){
System.out.println(i);
if(i<0)
break;
i--;
}
}
public static void main(String args[]){
f(5) ;
g(8);
}
}
问题刚刚解决,是因为数据不太规范,本身id和父id相同,导致溢出。当时我就想到这个问题了,但是以为客户的数据这么多年了,好多人在维护,不会有什么问题,实在走投无路了,就查了下数据,果真发现问题了!还是谢谢各位,以后多多探讨,结贴了!