Rest 使用Jetty以编程方式创建servlet路径和变量
我希望能够以编程方式在Jetty中用变量注册servlet上下文路径,但我似乎不知道如何在Jetty中单独完成 有一些要求使其变得困难:Rest 使用Jetty以编程方式创建servlet路径和变量,rest,servlets,jax-rs,embedded-jetty,path-variables,Rest,Servlets,Jax Rs,Embedded Jetty,Path Variables,我希望能够以编程方式在Jetty中用变量注册servlet上下文路径,但我似乎不知道如何在Jetty中单独完成 有一些要求使其变得困难: 我必须使用Maven进行依赖关系管理 我必须使用javax.servlet.Filter的特定子类进行身份验证 考虑到与现有环境的冲突,像Play这样漂亮的东西!Grails已经过时了,即使JAX-RS注释很整洁,我也希望能够在配置文件中以编程方式更改这些内容,而无需重新编译 基本上,我正在寻找类似的路线管理,但我无法找到一个起点,开始朝这个方向前进 我可以使
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
// add other random stuff to the context
context.addServlet(new ServletHolder(new ThingServlet()),"/things/{id}");
// the above line could easily come from a config file using Class.forName, etc.
server.start();
server.join();
我完全接受建议,嵌入式网络服务器,等等。我习惯于在Django/Pylons/Werkzeug中写更多关于他们路线的文章,几天前我被卷入其中,这就是我目前必须处理的问题,因此任何指导或帮助都将不胜感激