动态菜单加载失败,,
TreeDao.java:
package com.lym.struts.business;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.lym.struts.model.DBConnection;
public class TreeDao {
private Connection conn = null;
private PreparedStatement ps = null;
private DBConnection dbconn = null;
public TreeDao() {
dbconn = new DBConnection();
conn = dbconn.getDBConnection();
}
public List<TreeBean> allTree() {
List<TreeBean> list = new ArrayList<TreeBean>();
TreeBean bean = null;
String sql = "select id, pid, name from tree";
try {
ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next()){
bean = new TreeBean();
bean.setId(rs.getString("id"));//节点编号
bean.setPid(rs.getString("pid"));//父节点编号
bean.setName(rs.getString("name")); //节点名称
//bean.setUrl(rs.getString("url"));//链接地址
list.add(bean);
}
}
catch (
SQLException ex){
}
return list;
}
}
tree.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<jsp:useBean id="treeDao" scope="page" class="com.lym.struts.business.TreeDao" />
<%
List<?> list = treeDao.allTree();
session.setAttribute("treeList", list);
//out.println(list);
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'tree.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<