我的项目在 Jetty 6 上运行良好,但是在 Jetty 7.5+ 上(我检查了 7.5、8.1 和 9.0)我No such servlet
在 Jetty 启动时遇到异常(我猜是项目部署)。
web.xml
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>myproject.servlets.TestServlet</servlet-class>
</servlet>
TestServlet.java
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 3992344538270432732L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1>Hello Servlet Get</h1>");
out.println("</body>");
out.println("</html>");
}
}