【问题标题】:Map an AbstractHandler to specific path for an embedded Server (Jetty)将 AbstractHandler 映射到嵌入式服务器(Jetty)的特定路径
【发布时间】:2013-05-21 14:59:55
【问题描述】:

对于 JUnit 测试,我想向我的嵌入式码头服务器添加一个处理程序。我可以通过这段代码做到这一点:

    Server server = new Server(8080)

    Handler h = new AbstractHandler() {

        @Override
        public void handle(String target, Request baseRequest,
                HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException {
            // do something

        }
    };
    server.setHandler(h);

然后对我的服务器的每个调用都由这个处理程序处理。但我只想处理对特定路径的请求,例如:'http://localhost:8080/test'。我发现了一些使用 'org.mortbay.jetty.servlet.Context' 类来归档的示例。但我想这已经很老了,已经不存在了?

【问题讨论】:

    标签: java testing junit jetty


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2022-01-08
    • 2013-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多