编译servlet时出错

时间:2013-12-26 15:24:00

标签: java java-ee servlets compiler-errors

我写了一个简单的servlet:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class TestingServlet extends HttpServer {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        out.println("<H1>Hello world</H1>");
    }
}

我试图编译它并获得:

  

TestingServlet.java:6:错误:找不到符号公共类   TestingServlet扩展了HttpServer {                                       ^符号:类HttpServer 1错误

我该如何解决?

1 个答案:

答案 0 :(得分:5)

我相信您正在寻找javax.servlet.http.HttpServlet

public class TestingServlet extends HttpServlet {

您导入的任何软件包中都没有HttpServer个类。