本文整理匯總了Java中org.eclipse.jetty.server.handler.MovedContextHandler類的典型用法代碼示例。如果您正苦於以下問題:Java MovedContextHandler類的具體用法?Java MovedContextHandler怎麽用?Java MovedContextHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MovedContextHandler類屬於org.eclipse.jetty.server.handler包,在下文中一共展示了MovedContextHandler類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: before_suite
import org.eclipse.jetty.server.handler.MovedContextHandler; //導入依賴的package包/類
@BeforeSuite
public void before_suite() throws Exception {
// Launch Protractor's own test app on http://localhost:8080
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(6));
ServerConnector connector = new ServerConnector(webServer, new HttpConnectionFactory());
connector.setPort(8080);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("src/test/webapp");
HandlerList handlers = new HandlerList();
MovedContextHandler effective_symlink = new MovedContextHandler(webServer, "/lib/angular", "/lib/angular_v1.2.9");
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
driver = new ChromeDriver();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ngWebDriver = new NgWebDriver(driver);
}
示例2: createHandlers
import org.eclipse.jetty.server.handler.MovedContextHandler; //導入依賴的package包/類
private HandlerCollection createHandlers() {
final WebAppContext webApp = new WebAppContext();
webApp.setContextPath(contextPath);
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
// GZIP handler
final GzipHandler gzipHandler = new GzipHandler();
gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
gzipHandler.setIncludedMethods("GET", "POST");
gzipHandler.setCompressionLevel(9);
gzipHandler.setHandler(webApp);
if (Strings.isNullOrEmpty(webAppLocation)) {
webApp.setWar(getShadedWarUrl());
} else {
webApp.setWar(webAppLocation);
}
// Request log handler
final RequestLogHandler log = new RequestLogHandler();
log.setRequestLog(createRequestLog());
// Redirect root context handler
MovedContextHandler rootRedirect = new MovedContextHandler();
rootRedirect.setContextPath("/");
rootRedirect.setNewContextURL(contextPath);
rootRedirect.setPermanent(true);
// Put rootRedirect at the end!
return new HandlerCollection(log, gzipHandler, rootRedirect);
}
示例3: startHttpd
import org.eclipse.jetty.server.handler.MovedContextHandler; //導入依賴的package包/類
@BeforeClass
public static void startHttpd() throws Exception {
httpd = new HttpdForTests();
httpd.addHandler(new MovedContextHandler(null, "/redirect", "/out"));
httpd.addStaticContent("cheese");
httpd.start();
}