我在JSP编写了一个输出数据库内容某两列内容的程序,怎么将内容分别输出到两个可选框里面啊?程序为:
<formid="test"method="post"><selectid="code"name="plugin"><optionvalue=>请选择</option><...
<form id="test" method="post" >
<select id="code" name="plugin">
<option value=>请选择</option>
<option value="1">钢材</option>
<option value="2">铸铁</option>
</select>
<input type="submit" value="提交">
</form>
<%
String num = request.getParameter("plugin");
int id= Integer.parseInt(num);
String st="select * from steel";
String ti="select * from titanium";
String Qq;
if(id==1)
{ Qq=st;}
else
{ Qq=ti;}
Connection con = null;
Statement sm = null;
ResultSet rs = null;
try
{
Class.forName("org.postgresql.Driver").newInstance();
String url="jdbc:postgresql://localhost/Anti-fatigue Design";
String user="postgres";
String password="123456";
con = DriverManager.getConnection(url,user,password);
sm = con.createStatement();
rs = sm.executeQuery(Qq);
while(rs.next())
{
out.println(rs.getString(2)+",");
out.println(rs.getString(3)+","); }
}
catch(Exception e)
{
e.printStackTrace();
}
%>
这样只会将数据输出到截面,我该在哪里添加另外两个可选框呢?具体该怎么修改呢? 展开
<select id="code" name="plugin">
<option value=>请选择</option>
<option value="1">钢材</option>
<option value="2">铸铁</option>
</select>
<input type="submit" value="提交">
</form>
<%
String num = request.getParameter("plugin");
int id= Integer.parseInt(num);
String st="select * from steel";
String ti="select * from titanium";
String Qq;
if(id==1)
{ Qq=st;}
else
{ Qq=ti;}
Connection con = null;
Statement sm = null;
ResultSet rs = null;
try
{
Class.forName("org.postgresql.Driver").newInstance();
String url="jdbc:postgresql://localhost/Anti-fatigue Design";
String user="postgres";
String password="123456";
con = DriverManager.getConnection(url,user,password);
sm = con.createStatement();
rs = sm.executeQuery(Qq);
while(rs.next())
{
out.println(rs.getString(2)+",");
out.println(rs.getString(3)+","); }
}
catch(Exception e)
{
e.printStackTrace();
}
%>
这样只会将数据输出到截面,我该在哪里添加另外两个可选框呢?具体该怎么修改呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询