我正在尝试以编程方式在Jetty7.0中注册一个servlet。我找到的所有例子都是针对6号码头的,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服务
. 谢谢