如何在嵌入式Jetty WebAppContext中获取context-params?

时间:2017-11-30 17:52:45

标签: java web-applications jetty embedded-jetty

我正在使用jetty运行嵌入式服务器,并提供资源库和描述符来启动服务器。我的web.xml文件中有一些上下文参数,我需要阅读。我尝试过搜索,但无法找到方法。 这是我的代码。

static int port = 8081;
static Server server;

public static void start(String[] args) {

        while (!stop) {

            server = new Server(port);

            String wardir = "webapps/war";

            WebAppContext context = new WebAppContext();
            context.setResourceBase(wardir);
            String webXML = "/WEB-INF/web.xml";
            context.setDescriptor("wardir + webXML");
            context.setConfigurations(new Configuration[]{
                new AnnotationConfiguration(), new WebXmlConfiguration(),
                new WebInfConfiguration(), new TagLibConfiguration(),
                new PlusConfiguration(), new MetaInfConfiguration(),
                new FragmentConfiguration(), new EnvConfiguration()});

            context.setContextPath("/");
            context.setParentLoaderPriority(true);
            server.setHandler(context);


            try {
            server.start();
            server.dump(System.err);
            server.join();

        } catch (Exception e) {

        }

    }
}

如何阅读web.xml文件中设置的上下文参数?

0 个答案:

没有答案
相关问题