简体   繁体   English

以编程方式在Jetty 7中注册servlet

[英]Programmatically registering a servlet in Jetty 7

I'm trying to register a Servlet in Jetty 7.0 programmatically. 我正在尝试以编程方式在Jetty 7.0中注册Servlet。 All the examples I find are for Jetty 6, and Jetty 7 is quite different. 我找到的所有例子都是Jetty 6,而Jetty 7则完全不同。 Here is my server side: 这是我的服务器端:

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");
     }

}

The result of this test is the sever starts, but the client fails on connect: Caused by: java.io.FileNotFoundException: http://localhost:8080/hessian-service 此测试的结果是服务器启动,但客户端在连接时失败:引起:java.io.FileNotFoundException: http:// localhost:8080 / hessian-service

I see nothing in my browser at http://localhost:8080/hessian-service . 我在浏览器中看不到http:// localhost:8080 / hessian-service Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM