本文整理匯總了Java中org.apache.catalina.startup.Tomcat.initWebappDefaults方法的典型用法代碼示例。如果您正苦於以下問題:Java Tomcat.initWebappDefaults方法的具體用法?Java Tomcat.initWebappDefaults怎麽用?Java Tomcat.initWebappDefaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.catalina.startup.Tomcat
的用法示例。
在下文中一共展示了Tomcat.initWebappDefaults方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doClassUnloadingPrep
import org.apache.catalina.startup.Tomcat; //導入方法依賴的package包/類
private DefaultInstanceManager doClassUnloadingPrep() throws Exception {
Tomcat tomcat = getTomcatInstance();
// Create the context (don't use addWebapp as we want to modify the
// JSP Servlet settings).
File appDir = new File("test/webapp-3.0");
StandardContext ctxt = (StandardContext) tomcat.addContext(
null, "/test", appDir.getAbsolutePath());
// Configure the defaults and then tweak the JSP servlet settings
// Note: Min value for maxLoadedJsps is 2
Tomcat.initWebappDefaults(ctxt);
Wrapper w = (Wrapper) ctxt.findChild("jsp");
w.addInitParameter("maxLoadedJsps", "2");
tomcat.start();
return (DefaultInstanceManager) ctxt.getInstanceManager();
}
示例2: loadServlets
import org.apache.catalina.startup.Tomcat; //導入方法依賴的package包/類
/**
* 加載一些必須的servlet
* @param context tomcat的上下文
*/
protected void loadServlets(Context context) {
Tomcat.initWebappDefaults(context);
config.getExclutions().forEach(exclude -> {
context.addServletMappingDecoded(exclude, "default");
});
// 核心調度器
Wrapper dispatcher = Tomcat.addServlet(context, "Nymph", CORE_REQUEST_DISPATCHER);
dispatcher.setAsyncSupported(true);
dispatcher.addMapping(config.getUrlPattern());
}
示例3: doTestELMisc
import org.apache.catalina.startup.Tomcat; //導入方法依賴的package包/類
private void doTestELMisc(boolean quoteAttributeEL) throws Exception {
Tomcat tomcat = getTomcatInstance();
// Create the context (don't use addWebapp as we want to modify the
// JSP Servlet settings).
File appDir = new File("test/webapp-3.0");
StandardContext ctxt = (StandardContext) tomcat.addContext(
null, "/test", appDir.getAbsolutePath());
// Configure the defaults and then tweak the JSP servlet settings
// Note: Min value for maxLoadedJsps is 2
Tomcat.initWebappDefaults(ctxt);
Wrapper w = (Wrapper) ctxt.findChild("jsp");
String jspName;
if (quoteAttributeEL) {
jspName = "/test/el-misc-with-quote-attribute-el.jsp";
w.addInitParameter("quoteAttributeEL", "true");
} else {
jspName = "/test/el-misc-no-quote-attribute-el.jsp";
w.addInitParameter("quoteAttributeEL", "false");
}
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + jspName);
String result = res.toString();
assertEcho(result, "00-\\\\\\\"${'hello world'}");
assertEcho(result, "01-\\\\\\\"\\${'hello world'}");
assertEcho(result, "02-\\\"${'hello world'}");
assertEcho(result, "03-\\\"\\hello world");
assertEcho(result, "2az-04");
assertEcho(result, "05-a2z");
assertEcho(result, "06-az2");
assertEcho(result, "2az-07");
assertEcho(result, "08-a2z");
assertEcho(result, "09-az2");
assertEcho(result, "10-${'foo'}bar");
assertEcho(result, "11-\\\"}");
assertEcho(result, "12-foo\\bar\\baz");
assertEcho(result, "13-foo\\bar\\baz");
assertEcho(result, "14-foo\\bar\\baz");
assertEcho(result, "15-foo\\bar\\baz");
assertEcho(result, "16-foo\\bar\\baz");
assertEcho(result, "17-foo\\'bar'\\"baz"");
}