我在 jsp 页面的隐藏字段中有一些数据
<input type=hidden id="thisField" name="inputName">
如何在提交时访问或传递此字段到另一个页面?
要传递该值,您必须包含隐藏值value="hiddenValue"
in the <input>
像这样的声明:
<input type="hidden" id="thisField" name="inputName" value="hiddenValue">
然后,通过访问请求对象的参数,以与恢复可见输入字段的值相同的方式恢复隐藏表单值。这是一个例子:
此代码位于您要隐藏该值的页面上。
<form action="anotherPage.jsp" method="GET">
<input type="hidden" id="thisField" name="inputName" value="hiddenValue">
<input type="submit">
</form>
然后在“anotherPage.jsp”页面上,您可以通过调用来恢复该值getParameter(String name)
隐式方法request
对象,如下所示:
<% String hidden = request.getParameter("inputName"); %>
The Hidden Value is <%=hidden %>
上述脚本的输出将是:
The Hidden Value is hiddenValue
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)