<select name="supplier">
<%
try {
Connection conn = JavaConnect.ConnectDb();
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT name FROM supplier ");
while(rs.next()) {
out.write("<option value ="+rs.getString("name")+"</option>");
}
rs.close();
stmt.close();
}
catch(Exception e) {
System.err.print("Sorry");
}
%>
</select>
我想在jsp頁面中填充組合框,並嘗試了上述,但即時獲取空的組合框。我已經研究了其他答案,但其中大多數似乎不起作用。從數據庫填充組合框
從現在起,您應該[避免](http://stackoverflow.com/a/3180202/1037210)使用Scriptlet。 – Lion