java.lang.ClassNotFoundException: HelloServlet at org.apache.catalina.loader.WebappClassLoader.loadClass

前端 未结 4 824
有刺的猬
有刺的猬 2021-01-06 15:38

I have a Hello World servlet in webapps/hello/WEB-INF/class/HelloServlet.class and I registered it as below in web.xml:



        
4条回答
  •  攒了一身酷
    2021-01-06 15:59

    Now you can just use annotations and it will be easier:

    package com.yourpackage;
    
    import java.io.IOException;
    import java.util.ResourceBundle;
    
    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 javax.servlet.http.HttpSession;
    
    /**
     * Servlet implementation class HelloWorldServlet
     */
    @WebServlet("/HelloWorldServlet")
    public class HelloWorldServlet extends HttpServlet {
    

    See WebServlet

    Cheers!!

提交回复
热议问题