Servlets 配置web.xml映射时遇到的问题

Servlets 配置web.xml映射时遇到的问题,servlets,web-applications,web.xml,Servlets,Web Applications,Web.xml,我刚刚开始学习web开发,在web.xml中映射SimpleServlet时,我一辈子都不知道自己做错了什么 这些是我的文件: 我的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:schemaLo

我刚刚开始学习web开发,在web.xml中映射SimpleServlet时,我一辈子都不知道自己做错了什么

这些是我的文件:

我的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"
    version="3.0">
    <display-name>JavaHelloWorldApp</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>SimpleServlet</servlet-name>
        <servlet-class>wasdev.sample.servlet.SimpleServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>SimpleServlet</servlet-name>
        <url-pattern>/SimpleServlet</url-pattern>
    </servlet-mapping>
</web-app>

我只是想让一个本地主机运行并访问JavaHelloWorldApp/SimpleServlet

您遇到了什么错误?@DanielBarbarian 404我假设您的web应用程序上下文根是JavaHelloWorldApp?当你的应用程序启动时,你有任何错误消息吗?@DanielBarbarian我没有收到任何错误,在谷歌搜索了一段时间后,我将确切的文件夹添加到我的web部署程序集中,它似乎可以工作,但是现在,在我修改servlet并构建项目之后,我的更改似乎没有对我的本地hostOk产生任何影响,我注意到的一件事是,您在web.xml和servlet类中添加了一个servlet映射定义,两者都指向相同的路径。我知道,这可能会引起问题,因为容器可能认为这是两个单独的配置,因为它们是针对同一路径,它们发生碰撞。我会推荐其中一个,但不是两个都推荐。
package wasdev.sample.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class SimpleServlet
 */
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.getWriter().print("Hello World!");
    }

}