哪位遇到过这种情况,我的JAVASCRIPT是这样写的
var frm = document.getElementById("frmUser");frm.action = "../../servlet/ManagerServlet.do?id=" + id;
frm.method = "get";
frm.submit();
结果提交结束后URL里面变成了
http://localhost:8080/PatientCase/servlet/ManagerServlet.do?textfield=
这个样子.
 

解决方案 »

  1.   

    <form id="frmUser" name="frmUser" target="_blank">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="15" height="30"><img src="../../tab/images/tab_03.gif" width="15" height="30" /></td>
            <td width="1101" background="../../tab/images/tab_05.gif"><img src="../../tab/images/311.gif" width="16" height="16" /> <span class="STYLE4">用户设置列表</span></td>
            <td width="281" background="../../tab/images/tab_05.gif"><table border="0" align="right" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="60"><table width="87%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td class="STYLE1"><div align="center">
                            <input type="checkbox" name="checkboxAll" value="checkbox" onClick="selectAll(this)" />
                        </div></td>
                        <td class="STYLE1"><div align="center">全选</div></td>
                      </tr>
                  </table></td>
                  <td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td class="STYLE1"><div align="center"><img src="../../tab/images/001.gif" width="14" height="14" /></div></td>
                        <td class="STYLE1"><div align="center"><a href="#" >新增</a></div></td>
                      </tr>
                  </table></td>
                  <td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td class="STYLE1"><div align="center"><img src="../../tab/images/114.gif" width="14" height="14" /></div></td>
                        <td class="STYLE1"><div align="center"><a href="#" onClick="edit(1)" >修改</a></div></td>
                      </tr>
                  </table></td>
                  <td width="52"><table width="88%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td class="STYLE1"><div align="center"><img src="../../tab/images/083.gif" width="14" height="14" /></div></td>
                        <td class="STYLE1"><div align="center"><a href="#" onClick="del(1)" >删除</a></div></td>
                      </tr>
                  </table></td>
                </tr>
            </table></td>
            <td width="14"><img src="../../tab/images/tab_07.gif" width="14" height="30" /></td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="9" background="../../tab/images/tab_12.gif">&nbsp;</td>
            <td bgcolor="#f3ffe3">
            
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98" onMouseOver="changeto()"  onmouseout="changeback()">
              <tr>
                <td width="4%" height="26" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">选择</div></td>
                <td width="4%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">序号</div></td>
                <td width="13%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">用户编号</div></td>
                <td width="18%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">用户姓名</div></td>
                <td width="20%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">用户权限</div></td>
                <td width="20%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">创建时间</div></td>
                <td width="7%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">状态</div></td>
                <td width="7%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">编辑</div></td>
                <td width="7%" height="18" background="../../tab/images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">删除</div></td>
              </tr>
              <%
               int i = 0;
               for (Iterator<User> iter = userList.iterator(); iter.hasNext();)
               {
               User user = iter.next();
               i ++;
              %>
    <tr>
      <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE1">
        <input name="checkbox" type="checkbox" class="STYLE2" value="<%=user.getUserId() %>" />
      </div></td>
      <td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1"><%=i %></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="left" class="STYLE2 STYLE1">&nbsp;<%=user.getUserCode() %></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="left" class="STYLE2 STYLE1">&nbsp;<%=user.getUserName() %></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="left" class="STYLE2 STYLE1">&nbsp;<%=user.getPurview() == null?"":user.getPurview().getName() %></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="center" ><a href="#"><%=user.getCreateDate() == null?"":new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateDate()) %></a></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%="Y".equals(user.getIsUse())?"启用":"停用" %></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="center"><img src="../../tab/images/037.gif" width="9" height="9" /><span class="STYLE1"> [</span><a href="#" id="<%=user.getUserId() %>" onClick="edit(this)" >编辑</a><span class="STYLE1">]</span></div></td>
      <td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="../../tab/images/010.gif" width="9" height="9" /> </span><span class="STYLE1">[</span><a href="#" id="<%=user.getUserId() %>" onClick="del(this)">删除</a><span class="STYLE1">]</span></div></td>
    </tr>
              <%
               }
              %>
              
            </table>
            
            </td>
            <td width="9" background="../../tab/images/tab_16.gif">&nbsp;</td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td height="29"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="15" height="29"><img src="../../tab/images/tab_20.gif" width="15" height="29" /></td>
            <td background="../../tab/images/tab_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="25%" height="29" nowrap="nowrap"><span class="STYLE1">共&nbsp;<%=pageModel.getTotalRecords() %>&nbsp;条纪录,当前第&nbsp;<%=pageNo %>&nbsp;/&nbsp;<%=pageModel.getTotalPages() %>&nbsp;页,每页&nbsp;<%=pageSize %>&nbsp;条纪录</span></td>
                <td width="75%" valign="top" class="STYLE1"><div align="right">
                  <table width="352" height="20" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="62" height="22" valign="middle"><div align="right"><a href="#" onClick="turnToPage(<%=pageModel.getTopPageNo() %>)"><img src="../../tab/images/first.gif" width="37" height="15" /></a></div></td>
                      <td width="50" height="22" valign="middle"><div align="right"><a href="#" onClick="turnToPage(<%=pageModel.getPreviousPageNo() %>)"><img src="../../tab/images/back.gif" width="43" height="15" /></a></div></td>
                      <td width="54" height="22" valign="middle"><div align="right"><a href="#" onClick="turnToPage(<%=pageModel.getNextPageNo() %>)"><img src="../../tab/images/next.gif" width="43" height="15" /></a></div></td>
                      <td width="49" height="22" valign="middle"><div align="right"><a href="#" onClick="turnToPage(<%=pageModel.getBottomPageNo() %>)"><img src="../../tab/images/last.gif" width="37" height="15" /></a></div></td>
                      <td width="59" height="22" valign="middle"><div align="right">转到第</div></td>
                      <td width="25" height="22" valign="middle"><span class="STYLE7">
                        <input name="textfield" id="textfield" type="text" class="STYLE1" style="height:10px; width:25px;" size="5" />
                      </span></td>
                      <td width="23" height="22" valign="middle">页</td>
                      <td width="30" height="22" valign="middle"><a href="#" onClick="go(<%=pageModel.getTotalPages() %>)"><img src="../../tab/images/go.gif" width="37" height="15" /></a></td>
                    </tr>
                  </table>
                </div></td>
              </tr>
            </table></td>
            <td width="14"><img src="../../tab/images/tab_22.gif" width="14" height="29" /></td>
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
      

  2.   

    localhost:8080/PatientCase 提交后台自动会加上。
    id换成textfield 有点奇怪
    你直接把 action写在form中试试
      

  3.   

    你的意思是结果的URL里少了id=xxxx对吧应该是你form里面有个<input type="text" name="textfield" />
    用get方法的提交时候,你给的action里面的?后面那段id=xxx会被忽略,
    然后待提交的数据里面却有一个textfield文本框,值是空的,
    于是URL就变成那样了。解决方案:
    要么把method改成post,要么在form里加个隐藏的表单项name="id",
    <input type="hidden" id="the_hidden_id" name="id" />在提交的时候为它填入需要的值:
    var the_hidden_id = document.getElementById('hidden_id');
    the_hidden_id.value = id;这样提交后URL就形如
    http://localhost:8080/PatientCase/servlet/ManagerServlet.do?id=xxx&textfield=
      

  4.   

    总而言之,就是GET方法提交时你给的action的问号后面的查询字符串会被忽略掉。
      

  5.   

    但是还有一个奇怪的就是,如果我把FORM放在不包含那个TEXT的地方的时候,还是会把后面的全部忽略是为什么?
      

  6.   

    只要用GET方法就会的吧,
    这跟form里有多少要提交的数据没关系。如果你一定要用GET方法,就用我前面添加input type="hidden"的方法来提交你本来写在action中的?id=...这部分。
    不然就用POST方法提交,更简单一点。