Java 提交带有多个下拉框的表单?

Java 提交带有多个下拉框的表单?,java,javascript,forms,servlets,jdbc,Java,Javascript,Forms,Servlets,Jdbc,在下面的代码中,我在一个表单中有多个下拉框。在下拉框中,我显示默认值。 但当用户登录后,用户可以更改下拉列表中的值并单击提交按钮 <form method="post" id="myForm" name="myForm"> <% while(rs1.next())

在下面的代码中,我在一个表单中有多个下拉框。在下拉框中,我显示默认值。 但当用户登录后,用户可以更改下拉列表中的值并单击提交按钮

<form method="post" id="myForm" name="myForm">

                                 <%            
                                            while(rs1.next())
                                                {

                                  %>            

                                                 <table id="main_table" style="width: 600px; border: 0px solid #ccc;  padding: 1px; border-spacing: 1px;  ">


                                                 <tbody>
                                                 <tr class="ab" style="background-color:#3f92aa; color:white; width:600px; ">
                                                 <td colspan="2" class="flip" style="width:125px; font-size:14px; text-align:left; font-family:Palatino Linotype;"><%=rs1.getString(3) %><input type="hidden" name="statename" value="Goa"></td>
                                                 <td colspan="2" class="flip"  style="width:125px; font-size:14px; text-align:center; font-family:Palatino Linotype;"><%=rs1.getString(4) %></td>
                                                 <td colspan="2" class="flip"  style="background-color:#cb3315; width:125px; font-size:14px; text-align:center; font-family:Palatino Linotype;"><%=rs1.getString(5) %></td>


                                                 <td colspan="2" style="width:125px; font-size:13px; font-family:Palatino Linotype; text-align:center;">

                                                  <table style="border: 0px;border-spacing: 0px;padding: 0px;">
                                                   <tr>

                                                                      <td>&nbsp;</td>
                                                                              <td>
                                                                                      <select name="<%=rs1.getString(3) %>">
                                                                                              <option value="<%=rs1.getString(5) %>"><%=rs1.getString(5) %></option>
                                                                               <%
                                                                                Statement stmt2=null;
                                                                                DBconnection db2=new DBconnection();
                                                                                Connection con2=db2.dbConn();
                                                                                try{
                                                                                stmt2 = con2.createStatement();   
                                                                                         ResultSet rs2 = (ResultSet) stmt2.executeQuery("select distinct WinnerParty from election_history;");
                                                                                         while(rs2.next())
                                                                                         {
                                                                                 %>

                                                                                                 <option value="<%=rs2.getString(1) %>"><%=rs2.getString(1) %></option>

                                                                                <%

                                                                                          }
                                                                                     }
                                                                                     catch(SQLException e){
                                                                                     e.printStackTrace();
                                                                                     }
                                                                                     finally{
                                                                                     con2.close();
                                                                                     stmt2.close();
                                                                                      }

                                                                                 %> 

                                                                                      </select>
                                                                                      </td>
                                                                                      </tr>
                                                                                      </table>



                                                                   </td>
                                                                   </tr>
                                                                   </tbody>



                                     </tbody>



                                      </table>
                                      </form> 
但这里我的问题是,当我提交表单时,我在servlet中只得到一个下拉列表值(CSelected),正如您在输出中看到的,其余值为null。
有谁能告诉我这里有什么问题吗???

如果您有多个下拉列表,所有下拉列表都命名为
statename
,请不要使用
String statenames=request.getParameter(“statename”)而不是使用:

String[] statenames = request.getParameterValues("statename");

请检查,你的表单提交了什么数据?没有,我解决了我的问题…实际上问题是表单标签被错误地关闭了;表单标记在表标记之前关闭。
inside editYPName...
Connected to the database
this is State name ===Goa
list of constituencies are==[Panaji, Mormugao]
Cname value is==Panaji
Cselected value is==null
Cname value is==Mormugao
Cselected value is==INC
String[] statenames = request.getParameterValues("statename");