gpt4 book ai didi

javascript - JSP 表单使用 post 传递值

转载 作者:行者123 更新时间:2023-12-03 08:38:10 25 4
gpt4 key购买 nike

好的,我正在尝试从页面上的表单传递值。

contact.jsp

<form id="myform" name="myform" method="post" action="confirm.jsp">
<p> Cell Line: <input type="text" name="cell" />
<p> Tissue Source<input type="text" name="source" />
<p> Temperature: <input type="text" name="temp" />
<p> Run-Time: <input type='text' name='run' />
<input type="submit" value="Request!"onclick="window.location.href='confirm.jsp'" />
/form>

confirm.jsp

<div class="controls">
<p><label>Cell Line:</label> <% String cell=request.getParameter("cell"); out.println(cell); %> </p>
<p><label>Tissue Source:</label> <% String source=request.getParameter("source"); out.println(source); %> </p>
<p><label>Temperature:</label> <% String temp=request.getParameter("temp"); out.println(temp); %> </p>
<p><label>Run-Time</label> <% String run=request.getParameter("first"); out.println(run); %> </p>
<p class="help-block"></p>
</div>

我将这些值传递给confirm.jsp。我在这里做错了什么?我需要在 web.xml 中设置 servlet吗?互联网上的所有内容都将我指向此代码,但迄今为止我得到的只是空值。

任何帮助都会很棒

最佳答案

相反

 <input type="submit" value="Request!"onclick="window.location.href='confirm.jsp'" />

使用

<input type="submit" value="Request!"/>

无需在web.xml文件中进行配置。因为在 form 标记中您编写了 action="confirm.jsp.

关于javascript - JSP 表单使用 post 传递值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33133319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com