Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp 通过单击提交按钮将值传递到下一页_Jsp - Fatal编程技术网

Jsp 通过单击提交按钮将值传递到下一页

Jsp 通过单击提交按钮将值传递到下一页,jsp,Jsp,朋友们, 我想将文本字段值传递到下一个jsp页面。当我尝试这样做时,下一个jsp页面总是显示该变量的空值。 请告诉我怎么做 我的代码是 <form name="lab" action="second.jsp" method="get"> <table> <tr> <td style="margin-left:10px">Enter Lab</td> <td><sel

朋友们, 我想将文本字段值传递到下一个jsp页面。当我尝试这样做时,下一个jsp页面总是显示该变量的空值。 请告诉我怎么做

我的代码是

   <form name="lab" action="second.jsp" method="get">
   <table>
            <tr>

    <td style="margin-left:10px">Enter Lab</td>
    <td><select name="labName">
        <option>--select lab---</option>
        <option>Lab-01</option>
        <option>Lab-02</option>
        <option>Lab-03</option>
        <option>Lab-04</option>
        <option>Lab-05</option>
        <option>Lab-06</option>
        <option>Lab-07</option>
        <option>Lab-08</option>
        <option>Lab-09</option>
        <option>Lab-10</option>
    </select></td>
</tr>
<tr>

    <td  width=100px>Enter Location</td>
    <td> <select name="location">
        <option>--select location--</option>
    <%  
        for(i=1;i<=60;i++)
        {
            %><option><%out.print(i);%></option><%
        }
    %>
        </select></td>
</tr>
<tr>

    <td   width=100px>Enter System ID </td>
    <td><input type=text name=lab name="sysId" value="Sys. Id" size=10></td>
</tr>
<tr>
    <td><hr><b</td>
    <td><hr></td>
</tr>
<tr>
    <td align=center class="cells"  width=100px><input type="submit" name=submit value=ADD hight=10px width=20px onclick="move();"></td>
    <td align=center class="cells"  width=10px ><input type=button name=submit value=cancel>
 </td>
</tr>
</table>
</form>

进入实验室
--选择实验室---
实验室-01
实验室-02
实验室-03
实验室-04
实验室-05
实验室-06
实验室-07
实验室-08
实验室-09
实验室-10
输入位置
--选择位置--

我在代码中没有看到元素。您应该将您的表包围起来,并将您的操作更改为POST。

以您在
second.jsp中使用
name
attribute两次的形式,这就是您在
second.jsp中获得
null
的原因

<input type=text name=lab name="sysId" value="Sys. Id" size=10>   
                 ↑        ↑  
然后在
second.jsp中

String id=request.getParameter("sysId");  //make sure you type correct name here
out.print(id);
它将打印:
这是sysId


不相关

我建议不要使用


--选择位置--

显示表单标签。或者您是否在表单标签中以第二个jsp页面的形式给出了操作?您的问题解决了吗?在表单中,您将表单操作更改为POST。我还注意到,在提交中有onclick=move()。请把它拿走。
<input type=text name="sysId" value="This is sysId" size=10>  
String id=request.getParameter("sysId");  //make sure you type correct name here
out.print(id);
<select name="location">
    <option>--select location--</option>
<%  
    for(i=1;i<=60;i++)
    {
        %><option><%out.print(i);%></option><%
    }
%>
    </select>
<select name="location">
    <option>--select location--</option>
    <c:forEach varStatus="i" begin="1" end="60">
    <option>${i.count}</option>
    </c:forEach>
</select>