尝试运行动态Web项目时出错404

时间:2018-05-04 13:22:38

标签: java html

我创建了一个名为DynamicPages的动态Web项目。每当我试图在服务器上运行它时,我收到错误404,其中说:源服务器没有找到目标资源的当前表示,或者不愿意透露存在该目标资源。

以下是我的web.xml文件:

 <?xml version="1.0" encoding="UTF-8"?>
 <element>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://xmlns.jcp.org/xml/ns/javaee"      
 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org
 /xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

  <display-name>DynamicPages</display-name>
 <welcome-file-list>
<welcome-file>pageone.html</welcome-file>
<welcome-file>pagetwo.html</welcome-file>
<welcome-file>output.jsp</welcome-file>

 </welcome-file-list>
 <servlet>
 <description></description>
<display-name>PageoneServlet</display-name>
<servlet-name>PageoneServlet</servlet-name>
<servlet-class>com.as.samples.PageoneServlet</servlet-class>
 </servlet>
<servlet-mapping>
<servlet-name>PageoneServlet</servlet-name>
<url-pattern>/PageoneServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>PagetwoServlet</display-name>
<servlet-name>PagetwoServlet</servlet-name>
<servlet-class>com.as.samples.PagetwoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PagetwoServlet</servlet-name>
<url-pattern>/PagetwoServlet</url-pattern>
</servlet-mapping>

</web-app>

以下是html文件pageone.html:

 <!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
  </head>
  <body>
  <h2>Student Details</h2>
 <form method = "post" action="PageoneServlet">
  Name     : <input type = "text" name = "name" /></br>
  Address:    <input type = "text" name = "address" /></br>
  Phone:   <input type="text" name = "phn" /> </br>
  <input type = "Submit"  value = "submit" />
  </form>
  </body>
  </html>

请提供帮助和建议。

1 个答案:

答案 0 :(得分:0)

尝试使用index.html作为welcome-file 如果没有,那么也在URL中传递pageone.html