在我的 JSP 中,我执行以下操作:
<!-- Bank manager's permissions -->
<!--more stuff goes here -->
<fieldset>
<legend>To open a new account</legend>
<form action="blablabla">
<input type="hidden" name="hdField" value="myValue" /> // note I pass a "myValue" as string
<a href="employeeTransaction1">Press here to continue</a>
</form>
</fieldset>
在我的 Servlet 中,我抓取了隐藏的输入:
@WebServlet("/employeeTransaction1")
public class Employee1 extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String getHiddenValue=request.getParameter("hdField");
System.out.println("Hidden field Value :"+getHiddenValue);
// forwards to the page employeeOpenNewAccount.jsp
request.getRequestDispatcher("/WEB-INF/results/employeeOpenNewAccount.jsp").forward(request, response);
}
}
并System.out.println
产生:null
在控制台
为什么我得到null
的不是我通过的实际值?
问候
编辑:
更改为后:
<fieldset>
<legend>To open a new account</legend>
<form action="/employeeTransaction1" method="GET">
<input type="hidden" name="hdField" value="myValue"/>
<a href="employeeTransaction1">Press here to continue</a>
</form>
</fieldset>
Anull
仍然出现在控制台上。