简体   繁体   English

将参数从jsp传递到servlet隐藏

[英]pass parameter from jsp to servlet hidden

This is my code in choose.jsp 这是我在select.jsp中的代码

<ul class="nav nav-pills  nav-stacked ">
<li>
<form action="persom" method="post">
<input type="hidden" name="hidden" value="<%= request.getParameter("eno") %>">
<input type="submit" value="PC">
</form> 
</li>
<li>Printer</li> 
<li>Scanner</li>
</ul

This is the code in servlet 这是servlet中的代码

String employee_num = request.getParameter("hidden") ;
PrintWriter pw= response.getWriter();
pw.println("<h2> " + employee_num + "</h2>"); 

It is returning null as output. 它返回null作为输出。 The value I'm passsing is from servlet through which i invoked the choose.jsp, please help. 我传递的值来自servlet,我通过它调用了choose.jsp,请帮忙。

I think parameter from servlet may be coming as Null . 我认为来自servlet的参数可能为Null。 Do one thing receive parameter in a variable some where else on the jsp page , and print it . 在jsp页面上的其他某处接收变量中的参数,然后打印出来。 Check if it is coming null from servlet side only or not . 检查它是否仅从servlet端变为null。 And if it is not null, just pass variable in the value field as, let's say <%=empNo%> .Let me know if that works :) 如果它不为null,只需在value字段中传递变量,例如<%= empNo%>。让我知道它是否有效:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM