tree.jsp集结

用法简介:

页面处理:
<jsp:useBean id="tree" class="com.hhsoft.houtai.RSReturnTree" />



<body>
    <div class="dtree" style="width: 100%; height: 95%; overflow:auto">
<script type="text/javascript" src="js/tree.js"></script>
<script type="text/javascript">
    <%=tree.getMenu1("T_tree")%>
document.write(d);

function openLocation(strUrl)
{
parent.frames[2].location.replace(strUrl)

}
function cwin()
{if(parent.testframeset.cols!='200,*')
{parent.testframeset.cols='200,*';
}
else{parent.testframeset.cols='-10,*';
}}
</script> 
</div>
  </body>



类中的处理:
package com.hhsoft.houtai;
import com.hhsoft.database.db;
import com.sun.rowset.CachedRowSetImpl;
public class RSReturnTree {
db dd=new db();

String menu="d = new dTree('d');\n d.add('001',-1,'后台维护列表');\n";
  public String getMenu1(String SQL){
  CachedRowSetImpl crs=null;
crs=dd.dbquery("select * from "+SQL+"","2008");
System.out.println("select * from "+SQL+"");
//不用再建立新的返回树的类,只需要把数据库的字段名相同就OK了,数据库名称为变量
try{
int bh=0;
while(crs.next()){
String mc=new String(crs.getString("mc"));
//System.out.println("111111111111111111");
String clj=new String(crs.getString("url"));
//System.out.println("11111122222221111111");
System.out.println(mc+"*******"+clj);
String img="";//new String(crs.getString("image"));
   menu+="d.add('"+bh+"','001','"+mc+"','"+clj+"','','','img/page.gif','','');\n";
bh++;
}

}catch(Exception e){
System.out.println("~~~~~getMenu1~返回时有异常~~~~~~~~");
}

return menu;
}
}

你可能感兴趣的:(sql,jsp,sun)