输入servlet地址,404NOT FOUND

输入servlet地址,404NOT FOUND_第1张图片
WelcomeServlet.java代码

package servlets;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.PrintWriter;//http://localhost:8080/test/servlets/WelcomeServletpublic class WelcomeServlet extends HttpServlet{ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { response.setContentType("text/html;charset=gb2312"); PrintWriter out=response.getWriter(); out.println("欢迎来到本系统!"); System.out.print(request.getRequestURL()); }}

web.xml代码


    
        WelcomeServlet
        servlets.WelcomeServlet
    
    
        WelcomeServlet
        /servlets/WelcomeServlet
    

原因:访问地址输入错误,不需要项目名test...虽然不知道为什么,但这样做就对了。

输入servlet地址,404NOT FOUND_第2张图片

你可能感兴趣的:(web)