【问题标题】:Servlet 3.0 HTTP 404 - The requested resource is not available [duplicate]Servlet 3.0 HTTP 404 - 请求的资源不可用[重复]
【发布时间】:2013-07-23 12:28:19
【问题描述】:

我遇到错误

HTTP 状态 404 - /WebServlet3.0/


输入状态报告

消息 /WebServlet3.0/

说明请求的资源不可用。


Apache Tomcat/7.0.42

这是我的 ServletAsync.java 文件,它位于 src -> com.example.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 ServletAsync
 */

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

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletAsync() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}

这是我的 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    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>WebServlet3.0</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>

</web-app>

这是我的 index.html 文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form name="input" action="ServletAsync" method="get">
        Write a text : <input type="text" name="input"> <input
            type="submit" value="Submit">
    </form>
</body>
</html>

你能纠正我的问题吗?为什么我收到此错误以及如何解决?我只想显示网页。

【问题讨论】:

    标签: java eclipse tomcat7 servlet-3.0


    【解决方案1】:

    问题已解决。我的项目名称是 webservlet3.0,当我将项目名称更改为 webservlet 时,我的项目就开始运行了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-02
      • 2020-04-29
      • 2016-09-18
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      • 2011-06-26
      • 2021-07-27
      相关资源
      最近更新 更多