0

我现在尝试了几个小时在 Eclipse 中运行一个简单的 hello world 程序,使用 servlet 但无法正常工作,看了一些教程但没有运气,如果有人可以请查看

我的错误和项目浏览器

我的错误和项目浏览器

我的 servlet 类

                 /**
    * Servlet implementation class HelloWorldServlet
         */
   public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

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

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World");
}

/**
 * @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_2_5.xsd" id="WebApp_ID" version="2.5">
         <display-name>FirstServlet</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>
      <description></description>
     <display-name>HelloWorldServlet</display-name>
     <servlet-name>HelloWorldServlet</servlet-name>
    <servlet-class>com.theopentutorials.servlets.HelloWorldServlet</servlet-class>
    </servlet>
   <servlet-mapping>
      <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/HelloWorldServlet</url-pattern>
     </servlet-mapping>
    </web-app>

4

1 回答 1

0

Delete your bin directory and Re-Compile your project. Also check if the newly generated classes are placed in bin

于 2013-02-10T13:58:45.020 回答