0
所以,這就是:在我的JSP頁面上,我希望使用存儲過程填充數據庫的下拉列表,該存儲過程期望在兩個無線電中選擇的國家的id
(即,如果你選擇美國,那個國家的國家就會被填補,如果你選擇尼加拉瓜,反之亦然)。正如我的問題所述,它沒有使用servlet,問題是我無法獲得所選無線電的value
(如果我傳遞一個數字而不是變量「country」,則組合被填充)。Dropdown JSP數據庫存儲過程沒有servlet
這是我的代碼:
<label for="state">State</label>
<select name="ddStates" id="ddStates">
<option value="-1">Select State...</option>
<%
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/nextnetcustomers", "root", "root");
int country = Integer.parseInt(request.getParameter("cntry"));
StringBuilder sb = new StringBuilder();
ResultSet rs = null;
PreparedStatement ps = null;
sb.append("{call SP_CATSTATES_LIST(?)}");
ps = conn.prepareCall(sb.toString());
ps.setInt(1, country);
rs = ps.executeQuery();
while (rs.next()) {
%>
<option value="<%=rs.getInt("IDCATSTATES")%>"><%=rs.getString("DESCRIPTION")%></option>
<%
}
} catch (Exception ex) {
ex.printStackTrace();
out.println("Error " + ex.getMessage());
}
%>
</select>
這是無線電裝置: 美國 < input type =「radio」name =「cntry」value =「2」/> NICARAGUA – Chris