如何使用表单从 JSP 传递参数到 Servlet,而这些参数不属于表单中的任何字段,并且不使用会话。我认为代码可能像下面的示例一样,但对我来说不起作用。请帮帮我。
在 index.jsp 中:
在 index.jsp 中:
<form method="Post" action="servlet">
<input type="text" name="username">
<input type="password" name="password">
<%
int z=1;
request.setAttribute("product_no", z);%>
<input type='submit' />
</form>
在servlet.java中:
int x=Integer.parseInt(request.getAttribute("product_no").toString());