-1

这是我的 Dem.html 页面在我单击“okeeee”按钮时无法正确执行,未生成事件

<form action="http://localhost:7000//DemoS/MyServlet" method="post">
</form>
<input type="text" name="e">
<input type="text" name="p">
<input type="submit" value="Okeeeeeeee">

post servlet 方法:

public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  String e=request.getParameter("e");
  String p=request.getParameter("p");out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
  out.println("  <BODY>");
  out.println(", using the POST method abhinav   hiii"+e+""+p);
  out.println("  </BODY>");out.println("</HTML>");
}
4

1 回答 1

0

您的输入必须包含在表单标签之间:

   <form action="http://localhost:7000//DemoS/MyServlet" method="post">
      <input type="text" name="e">
      <input type="text" name="p">
      <input type="submit" value="Okeeeeeeee">
   </form>
于 2013-04-12T09:06:29.550 回答