0
我想創建一個JSP動態菜單的數據是從數據庫中獲取.buti可以訪問這裏只有一個菜單是我的代碼和CSSjsp動態菜單隻顯示一個項目及其子項目?
<style>ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 14px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }
ul li.next {
position: absolute;
display: block;
float: left;
background:#E8E8E8;
font-size: 14px;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
}
ul li a.first {
background: #617F8A;
}
</style>
</head>
<body>
<div>
<%
//String connectionURL="jdbc:mysql://localhost:3306/dairy";
ArrayList list = new ArrayList();
ArrayList sublist = new ArrayList();
JSONArray jArray = new JSONArray();
try {
//Class.forName("oracle.jdbc.OracleDriver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
%>
<ul>
<%
String query1 = "select countryname,countryid from country";
Statement st1 = con.createStatement();
ResultSet rs1 = st1.executeQuery(query1);
while (rs1.next()) {
//for(rs1.size)
//out.println(rs1.size());
%>
<li>
<a href="#">
<%= rs1.getString(1)%>
</a>
<ul>
<%
String query2 = "select state from state where countryid='" + rs1.getString(2) + "'";
Statement st2 = con.createStatement();
ResultSet rs2 = st1.executeQuery(query2);
while (rs2.next()) {
%>
<li>
<a href="#">
<%= rs2.getString(1) %>
</a>
</li>
<%
}
%>
</ul>
</li>
<%
}
%>
</ul>
<%
} catch (Exception e1) {
}
%>
<%
%>
</div>
</body>
謝謝
我可以再次在子菜單下的子菜單 –
你是什麼意思?當然。搜索「twitter bootstrap」並查看一些示例。基本上,這是你可以用HTML做的事情。 – Sho
..讓我看看 –