HTTP状态404 - / reg

时间:2015-09-01 09:38:46

标签: jsp http servlets http-status-code-404 status

我正在尝试运行一个从jsp页面获取请求的servlet。 部署项目没有问题但是当我从jsp页面提交请求时,我的服务器没有导航到servlet文件。我收到的 HTTP状态404 - / reg 是我的web.xml文件。请帮帮我

   `<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Registration</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>

  </welcome-file-list>

  <servlet>
  <servlet-name>RegistrationServlet</servlet-name>
  <servlet-class>org.com.servlet.RegistrationServlet</servlet-class>
  </servlet>

  <servlet-mapping>
  <servlet-name>RegistrationServlet</servlet-name>
  <url-pattern>/reg</url-pattern>

  </servlet-mapping>


</web-app>`

这是我的JSP文件。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%! int i,j; %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Register</title>
</head>
<body>
<h3>Enter Your Details to Register</h3>
<form action ="/reg" method = "post">
First Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type = "text" name = "fname" size =25/><br>
Last Name  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type = "text" name = "lname" size =25/><br>
Date Of Birth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   Date  <select name="day">
<% for (int i = 1; i<32; i++){%>
<option value = <%=i%>> <%=i%></option>
<%}%>
</select>
Month <select name="month">
<%for(j=1;j<13;j++) {%>
<option value =<%=j %> > <%=j%></option>
<%}%>
</select>
Year <select name = "year">
<%for(int k = 1950; k<2010; k++){ %>
<option value =<%=k %> > <%=k%></option>
<%} %> 
</select><br>

Gender&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      <input type="radio" name="sex" value="male">Male
            <input type="radio" name="sex" value="female">Female <br>
Address &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    <input type = "text" name = "address" size =25/><br>
City    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <input type = "text" name = "city" size =25 /><br>
Country &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   <input type = "text" name = "country" size =25/><br>

<input type = "submit" value = "submit" />
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

在表单标签中使用action =“RegistrationServlet”。表单操作标记中的servlet调用是错误的。您的操作是“/ reg”,但是当它转到web.xml时,未找到servlet名称reg,因此显示404未找到错误。