我是一个登录页面,我在其中详细介绍了用户。
<form action="loginPage" method="post">
<table style="width: 30%">
<tr>
<th>user :</th>
<td align="center"><input type="text" name="uid" id="uid"></td>
</tr>
<tr>
<th>Password :</th>
<td align="center"><input type="text" name="password"
id="password"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit"
value="Submit"></td>
</tr>
</table>
</form>
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n=request.getParameter("uid");
String p=request.getParameter("password");
System.out.println("here");
......
out.close();
}
<servlet>
<servlet-name>Page</servlet-name>
<servlet-class>com.ui.login.login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Page</servlet-name>
<url-pattern>/loginPage</url-pattern>
</servlet-mapping>
问题是,当我点击提交按钮时,我收到一条错误消息,
>>The requested resource is not available.
答案 0 :(得分:1)
你应该在回复中写点什么。
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n=request.getParameter("uid");
String p=request.getParameter("password");
out.write("here");
out.flush();
}
答案 1 :(得分:1)
答案 2 :(得分:-1)
您在web.xml中的表单操作和网址格式应该匹配。 /表单标记的action属性中缺少/。