我有以下web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Example</display-name>
<!-- Servlets -->
<servlet>
<servlet-name>OrderServlet</servlet-name>
<servlet-class>OrderServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>OrderServlet</servlet-name>
<url-pattern>/CreateOrder</url-pattern>
</servlet-mapping>
</web-app>
以下是我的ServletClass
package de.uniba.dsg.dsam.client;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OrderServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public OrderServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/CreateOrder.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
[现在,当我转到链接LocalHost:8080:/CreateOrder
时,它不会访问它,只有当我访问它显示为HTTP Status 404 - Not Found
的链接时,才完全没有错误。我已经筋疲力尽了,因为它应该很容易地运行,但是它不起作用,我尝试只用web.xml
中定义的简单名称和jsp创建一个Servlet,但它不是可访问的,但是可以访问。
[servlet-class
应该包含完整的类层次结构,包括程序包:
<servlet-class>de.uniba.dsg.dsam.client.OrderServlet</servlet-class>