Java – the requested resource is not available for servlet 3.0 and Tomcat 7.0

My dynamic web module version is 3.0, and my Tomcat version is 7.0

When I navigate to the localhost: 8080 / simpleproject page, I don't know why it can't see my servlet XD

When I navigate to localhost: 8080 / simpleproject / firstservlet, I receive an error message indicating that the requested resource is not available!

This is my servlet:

@WebServlet(description = "the first servlet",urlPatterns = { "/firstservlet" })
public class FirstServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
//   response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    writer.println("<h1>Why can't See<h1>");
}

I'm not interested in my web XML does anything because all I know is that the 3.0 URL is mapped in a servlet

This is my file arrangement:)

Solution

Did you check the log file to see if some exceptions were thrown when loading / executing your servlet firstservlet?

Have you checked the contents of the war file to ensure that it is properly packaged and that the servlet class is in it (you can open the war file like a compressed file)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>