我使用 PrintWriter 来执行此代码:
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/* TODO output your page here. You may use following sample code. */
out.println("<html>");
out.println("<head>");
out.println("<title>Update Page</title>");
out.println("</head>");
out.println("<body>");
out.println("<center>");
out.println("<h1>Please choose ID</h1>");
out.println("</center>");
out.println("<table width='359' border='1' align='center'>");
out.println("<tr>");
out.println("<td width='103'>ID:</td>");
out.println("<th width='246'>");
out.println("<select name='ID' id='ID' style='width:170px;' >");
out.println("<option></option>");
out.println("</select>");
out.println("</th>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>Name:</td>");
out.println("<th><input type='text' name='Name' id='Name' style='width:170px;' /></th>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>Address:</td>");
out.println("<th><input type='text' name='Address' id='Address' style='width:170px;'/></th>");
out.println("</tr>");
out.println("<td>Email:</td>");
out.println("<th><input type='text' name='Email' id='Email' style='width:170px;'/></th>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>Phone Number:</td>");
out.println("<th><input type='text' name='Phone' id='Phone' style='width:170px;'/></th>");
out.println("</tr>");
out.println("<tr>");
out.println("<td></td>");
//=================
out.println("<td>");
out.println("<div>");
out.println("<input type='submit' name='FillValue' value='Fill ID' style='float:left'/>");
out.println("<form action='UpdateServlet' method='post'>");
out.println("<input type='submid' name='Submid' value='Submit' style='float:right'/>");
out.println("</form>");
out.println("</div>");
out.println("</td>");
out.println("</tr>");
//==============
out.println("</table>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
但是当我单击 Submid 按钮时出现问题,结果是:
HTTP 状态 404 - /DungDV01852_Lab1_2_3/UpdateServlet
类型状态报告
消息 /DungDV01852_Lab1_2_3/UpdateServlet
描述 请求的资源 (/DungDV01852_Lab1_2_3/UpdateServlet) 不可用。Apache Tomcat/6.0.29
我有类 updateServlet。另一个:我有 HTML:
<td>
<div>
<form action="FillServlet" method="post">
<input type="submit" name="FillValue" value="Fill ID" style="float:left"/>
</form>
<input type="submit" name="Submid" id="Submid" value="Submit"style="float:right"/>
</div>
</td>
它完全运行,但是当我使用 PrintWriter 编写新的 HTML 时也是错误的。请帮我。感谢大家