我试图用Jetty处理eclipse来完成超级简单的"Hello“Servlet。
我有一个Jetty适配器正在工作,但当我试图启动我的服务器时,我会得到以下错误;
servlet代码:
package My;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class My_Servlet
*/
@WebServlet("/My_Servlet")
public class My_Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public My_Servlet() {
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().println("<html><body><h1>My Servlet</h1></body></html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
}我所犯的错误:
Error 404 - Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:
/My_WS ---> o.e.j.w.WebAppContext{/My_WS,file:/home/user/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/My_WS/},/home/user/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/My_WS [failed]我在本地主机上看到的是:8080。
谢谢你的帮助,盖伊
编辑
我注意到我想念classVisitor ( Spring框架的哪个部分),为了支持我的简单程序,它已经成为一种麻烦。我可能会转到tomcat或者只是使用有装饰的码头
发布于 2013-03-09 23:36:41
值得注意的是,我使用Jetty和NetBeans,并且不使用NetBeans来运行jetty服务器。相反,我使用mvn jetty:run在命令行上运行它。
我认为您的问题是没有在web.xml文件中指定要处理请求的servlet。Java代码基本上是无关的。
发布于 2013-03-10 01:00:48
上下文http://localhost:8080/My_WS/上的webapp应用程序
您的Servlet在http://localhost:8080/My_WS/My_Servlet
您所看到的错误来自于您点击http://localhost:8080/,这并不是对您的简单场景做任何操作的设置。
https://stackoverflow.com/questions/15317000
复制相似问题