我正在 tomcat 7.0.37 和 eclipse 3.7 上开发一个示例 servlet。我目前的问题是让它可运行:(
//...imports and so on...
@WebServlet(value="/Hello")
public class AdminServlet extends HttpServlet
{
private static final long serialVersionUID = -1139419481702036147L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
super.doGet(req, resp);
PrintWriter writer = resp.getWriter();
writer.write("HelloWorld");
writer.close();
}
}
当我调用 URL 时,"http://localhost:8080/{webappname}/Hello"
一个窗口变为“状态 404 - 资源不可用”。有什么问题吗?
就像在大多数 Servlet 3.0 示例中一样 :(