我正在尝试以编程方式在Jetty 7.0中注册Servlet.我找到的所有例子都是Jetty 6,而Jetty 7则完全不同.这是我的服务器端:
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; public class Bootstrapper { public static void main(String[] args) throws Exception{ Server server = new Server(8080); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/context", true, false); servletContextHandler.addServlet(HessianService.class, "/hessian-service"); server.start(); System.out.println("started"); } }
此测试的结果是服务器启动,但客户端在连接时失败:引起:java.io.FileNotFoundException:http:// localhost:8080/hessian-service
我在浏览器中看不到http:// localhost:8080/hessian-service.谢谢
访问servlet的URL是http:// localhost:8080/context/hessian-service