这是我编写的示例servlet,没有什么特别之处:
@WebServlet("/SimpleServletPath")
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println("Hello");
}
}我在计算机上使用Tomcatv8.0的外部安装,这给出了查询http://localhost:8080/的正确页面。
在Dynamic Web Module中使用的Eclipse Luna是3.1。另外,由于我使用的是@WebServlet注释,所以我没有生成或使用web.xml文件。
不管我做什么,Tomcat总是给我运行Servlet时的错误。
HTTP Status 404 - /SimpleServlet/SimpleServletPath
type Status report
message /SimpleServlet/SimpleServletPath
description The requested resource is not available.
--------------------------------------------------------------------------------发布于 2015-03-10 13:24:26
我知道这听起来很傻,但是我在Eclipse中没有检查过Build Automatically。我想这是为了阻止我的项目被构建和部署到Tomcat中的任何更改。
刚刚检查了Build Automatically,现在一切都完美无缺了。
Servlet 3.1 (带/不带web.xml)和Servlet 2.5 (带web.xml)。
https://stackoverflow.com/questions/28963771
复制相似问题