将Jetty servlet添加到dropwizard [英] Add jetty servlet into dropwizard

查看:263
本文介绍了将Jetty servlet添加到dropwizard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Jetty servlet添加到使用dropwizard框架实现的现有服务器中.

I need to add jetty servlet into my already existing server implemented using dropwizard framework.

更具体地说:

  1. 我通过CRUD操作将一个宁静的资源Foo映射到url"localhost:8080/foo".
  2. 现在,我需要一个映射到网址"localhost:8080/bar"的码头小服务程序,并处理对该网址的所有请求(主要是GET和POST).

经过一番谷歌搜索后,我不知道如何执行此操作.有人可以给我指示或摘要吗?谢谢!

I could not get a clue how to do this after some googlings. Could someone please give me a direction or a snippet? Thanks!

推荐答案

如果您使用的是Dropwizard 0.6.2,则应该可以在run方法中执行以下操作:

If you're using Dropwizard 0.6.2 you should be able to do something like this in your run method:

ServletBuilder builder = environment.addServlet(myServlet, "/bar");

如果您使用的是Dropwizard 0.7.0,请尝试以下操作:

If you're using Dropwizard 0.7.0 try this:

environment.getApplicationContext().addServlet("org.example.MyServlet", "/bar");

这篇关于将Jetty servlet添加到dropwizard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆