jetty7内嵌代码配备

jetty7内嵌代码配置以war包形式启动:?String warPath ../project/target/project.warServer server

jetty7内嵌代码配置

以war包形式启动:

?

String warPath = "../project/target/project.war";        Server server = new Server(8080);                WebAppContext context = new WebAppContext();        context.setWar(warPath);        context.setContextPath("/");        context.setClassLoader(            Thread.currentThread().getContextClassLoader());         server.setHandler(context);         server.start();        server.join();
?

直接在项目中启动:

?

        String webapp = "../project/src/main/webapp";        Server server = new Server(8080);                WebAppContext context = new WebAppContext();        context.setDescriptor(webapp + "/WEB-INF/web.xml");        context.setResourceBase(webapp);        context.setContextPath("/");        context.setClassLoader(            Thread.currentThread().getContextClassLoader());         server.setHandler(context);         server.start();        server.join();
?

?