如何在jsp中使用表单传递隐藏值 [英] How to pass hidden values using form in jsp

查看:643
本文介绍了如何在jsp中使用表单传递隐藏值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

My code is as follows

<form method="post" action="Answer.jsp">
    <input type="submit" value="answer">
    <%String q_id=rs.getString("q_id"); %>
    <input type="hidden" value="<%out.print(q_id);%>"> 
</form> 

我想将 q_id 传递给页面 Answer.jsp 我得到了q_id的值,但我不知道如何传递(或使用任何不同的方法)值?

I want to pass q_id to page Answer.jsp I got the value of q_id but I didn't understand how to pass (or using any different method) value?

推荐答案

在您的JSP表单中,您将需要

In your JSP form you'll need

<form method="post" action="Answer.jsp">
    <input type="hidden" name="q_id" value="<%= rs.getString("q_id") %>">
    <input type="submit" value="Answer">
</form>

然后,您可以在<您的账户中收到 q_id em> Answer.jsp 作为

Then you can receive q_id in your Answer.jsp as

<p>Question ID: <%= request.getParameter("q_id") %></p>

或者,使用JSP EL(推荐)

or, using JSP EL (recommended)

<p>Question ID: ${param.q_id}</p>

这篇关于如何在jsp中使用表单传递隐藏值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆