我想在jsp查询数据库的每一条数据之后加一个列表框,怎么写?
在每一条数据后面加上一个下拉框,下拉框的值从数据库中获取,源码
<%
java.sql.Connection conn = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
ResultSet rs=null;
ResultSet rs1 = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
String dbUrl = "jdbc:mysql://127.0.0.1:3306/crmsystem";
String user = "root";
String password = "314159";
String sql="select * from tb_salechance where chance_state='未指派'";
String sql1="select manage_name from tb_manage";
conn=DriverManager.getConnection(dbUrl,user,password);
pstmt = (PreparedStatement)conn.prepareStatement(sql);
pstmt1 = (PreparedStatement)conn.prepareStatement(sql1);
rs=pstmt.executeQuery();
rs1=pstmt1.executeQuery();
out.println("<table>");
out.println("<tr><td>机会编号</td><td>客户名称</td><td>客户电话</td><td>客户性别</td><td>客户地区</td><td>设 备种类</td><td>指派状态</td><td>人员指派</td></tr>");
while(rs.next()){
out.println("<tr><td>");
out.println(rs.getInt(1));
out.println("</td><td>");
out.println(rs.getString(2));
out.println("</td><td>");
out.println(rs.getString(3));
out.println("</td><td>");
out.println(rs.getString(6));
out.println("</td><td>");
out.println(rs.getString(7));
out.println("</td><td>");
out.println(rs.getString(8));
out.println("</td><td>");
out.println(rs.getString(5));
out.println("</td><td>");
}
out.println("</table>");
}catch(Exception e){
out.println(e);
}
rs.close();
pstmt.close();
rs1.close();
pstmt.close();
conn.close();
%>
------解决方案--------------------拼接一个类似下面的字符串,然后将其写到一个<td>中
<select id="s1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>