大家看我的代码:
为什么只能接收到第一个值而不是所有的值呢?
//updade_cou.jsp
<table width="563" height="23" border="1" cellpadding="0" cellspacing="0" bordercolor="#99FFFF"  align="center">
      <form id="form2" name="form2" method="post" action="del_add_cou.jsp">
      <tr align="center">
        <th width="84" height="17">课程号</th>
        <th width="358">课&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;程</th>
<th width="99"><input type="image" name="imageField2" src="../../image/apply.png" /></th>
      </tr>
  <%
  while(rsCourse.next())
  {
  %>

    <tr align="center">
         <td width="84" height="17"><%=rsCourse.getString("Cno")%></td>
         <td width="358"><%=rsCourse.getString("Cname")%></td>
   <td width="99">
     <input name="sno" type="hidden" id="sno" value="<%=strId%>" />
     <input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
           <%
           if(rsCno.next())
   {
    i++;
   %>
    <label>
    <input name="check" type="checkbox" id="check" checked="checked"  value="<%=i%>"/>
    </label>
                
            <%
}

            else
            {
j++;
//out.print(j);
    %>
            <label>
    <input name="uncheck" type="checkbox" id="uncheck" />
    </label>
             <%
             }
 %>
           </td>
       </tr>
</form>
  <%
  }
  out.print(i);
  %>
  <br>
      <%
  out.print(j);
   %>
    </table>//del_add_cou.jsp<%
chStr trim = new chStr();String strSno=trim.chStr(request.getParameter("sno"));
String strCno=trim.chStr(request.getParameter("Cno"));
//String strUncheck[] = {""};
//String strChecked[] = {""};
String[] strUncheck = request.getParameterValues("uncheck");
String[] strChecked = request.getParameterValues("check");
for(int i=0;strUncheck !=null && i<strUncheck.length; i++)
{
out.print(strUncheck[i]);
}
for(int i=0;strChecked !=null && i<strChecked.length; i++)
{
out.print(strChecked[i]);
}
%>

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【tidelgl】截止到2008-06-23 22:42:26的历史汇总数据(不包括此帖):
    发帖数:0                  发帖分:0                  
    结贴数:0                  结贴分:0                  
    未结数:0                  未结分:0                  
    结贴率:-------------------结分率:-------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

      <input name="sno" type="hidden" id="sno" value="<%=strId%>" />
                 <input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
    红色去掉,看下Cno有没有值
      

  3.   

    因为你往隐藏域存值得时候他默认没分割成数组
    String[] strUncheck = request.getParameterValues("uncheck").split(",");//分割下字符
    String[] strChecked = request.getParameterValues("check").split(",");//分割下字符
      

  4.   

    刚才代码是调试时修改了的..
    前一部分真实是这样的:
    //update_cou.jsp
     <table width="563" height="23" border="1" cellpadding="0" cellspacing="0" bordercolor="#99FFFF"  align="center">
          <form id="form2" name="form2" method="post" action="del_add_cou.jsp">
          <tr align="center">
            <th width="84" height="17">课程号</th>
            <th width="358">课&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;程</th>
    <th width="99"><input type="image" name="imageField2" src="../../image/apply.png" /></th>
          </tr>
      <%
      while(rsCourse.next())
      {
      %>

        <tr align="center">
             <td width="84" height="17"><%=rsCourse.getString("Cno")%></td>
             <td width="358"><%=rsCourse.getString("Cname")%></td>
       <td width="99">
         <input name="sno" type="hidden" id="sno" value="<%=strId%>" />
         <input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
               <%
               if(rsCno.next())
       {
        i++;
       %>
        <label>
        <input name="check" type="checkbox" id="check" checked="checked"  value="<%=rsCourse.getString("Cno")%>"/>
        </label>
                    
                <%
    }

                else
                {
    j++;
    //out.print(rsCourse.getString("Cno"));
        %>
                <label>
        <input name="uncheck" type="checkbox" id="uncheck" value="<%=rsCourse.getString("Cno")%>"/>
        </label>
                 <%
                 }
     %>
               </td>
           </tr>
    </form>
      <%
      }
      out.print(i);
      %>
      <br>
          <%
      out.print(j);
       %>
        </table>
      

  5.   

    三楼的办法不行啊..
     找不到符号
    符号: 方法 split(java.lang.String)
    位置: 类 java.lang.String[]
    String[] strUncheck = request.getParameterValues("uncheck").split(",");
                                                               ^
      

  6.   


    split(" ");//直接这样看看
      

  7.   

    http://topic.csdn.net/u/20080617/15/589c60c6-5d78-41c7-8945-eae33484e5cd.html看下
      

  8.   

    你先out.print()打出来看看  就可以知道用什么分割了阿.
      

  9.   

    已经输出测试了啊..
    就是只有第一个元素的值..
    //del_add_cou.jsp<%
    chStr trim = new chStr();String strSno=trim.chStr(request.getParameter("sno"));
    String strCno=trim.chStr(request.getParameter("Cno"));
    //String strUncheck[] = {""};
    //String strChecked[] = {""};
    String[] strUncheck = request.getParameterValues("uncheck");
    String[] strChecked = request.getParameterValues("check");
    for(int i=0;strUncheck !=null && i<strUncheck.length; i++)
    {
            out.print(strUncheck[i]);
    }
    for(int i=0;strChecked !=null && i<strChecked.length; i++)
    {
            out.print(strChecked[i]);
    }
    %>
      

  10.   

    String[] strUncheck = request.getParameterValues("uncheck");
    直接得到的就是数组了