【发布时间】:2015-08-04 05:54:22
【问题描述】:
我在 mysql 数据库中有 2 列,名称和值。这些列有多行。我需要在 jsp 页面的下拉列表中显示名称,根据选择的名称,它的值应该显示在下面。 请提供一段代码。
我的一段代码:-
<%
try{
conn= ConnectionHelper.getConnection();
pstmt=conn.prepareStatement("select name, value from myDb ");
rs=pstmt.executeQuery();
%>
<select id="selectDropDown" name="filename" >
<% while(rs.next()){ %>
<option ><%= rs.getString("name")%> </option>
<% } %>
</select>
value :<%= rs.getString("value")%>
<%
} catch (SQLException sq) {
out.println("OOps! Something went wrong. DB error!");
sq.printStackTrace();
} catch (Exception e) {
out.println("OOps! Something went wrong.");
e.printStackTrace();
} finally {
}
%>
【问题讨论】:
-
到目前为止你做了什么..请提供你的代码..
-
已附上一段代码..
标签: mysql jsp select drop-down-menu