我在eclipse里用Java编了一个Servlet的下程序 总是报

HTTP Status 404 - /JD6/servlet/zxc.TestServlet

--------------------------------------------------------------------------------

type Status report

message /JD6/servlet/zxc.TestServlet

description The requested resource is not available.

--------------------------------------------------------------------------------

Apache Tomcat/7.0.69

希望大神帮忙
我的代码package zxc;

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;
import java.io.PrintWriter;

public class TestServlet extends HttpServlet {

public TestServlet() {
super();
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw=response.getWriter();
pw.println("hello");
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

doGet(request, response);
}

}

出现404的几种情况:
1.输入的地址有误(应用名大小写不正确,名称拼写不正确)
2.在web.xml文件中<servlet>和<servlet-mapping>中的两个<servlet-name>不一致
3.没有将工程部署到Tomcat的webapps下面
4.Web工程部署时的结构没有遵循Servlet的规范追问

我的WebContent下的WEB—INF下怎么没有web.xml文件

温馨提示:内容为网友见解,仅供参考
第1个回答  2016-05-19
信息太少 而且给的地方不对 需要看你web.xml配置
相似回答