本文整理汇总了Java中org.apache.catalina.Context.addWelcomeFile方法的典型用法代码示例。如果您正苦于以下问题:Java Context.addWelcomeFile方法的具体用法?Java Context.addWelcomeFile怎么用?Java Context.addWelcomeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Context
的用法示例。
在下文中一共展示了Context.addWelcomeFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWebappDefaults
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Static version of {@link #initWebappDefaults(String)}
* @param ctx The context to set the defaults for
*/
public static void initWebappDefaults(Context ctx) {
// Default servlet
Wrapper servlet = addServlet(
ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
servlet.setLoadOnStartup(1);
servlet.setOverridable(true);
// JSP servlet (by class name - to avoid loading all deps)
servlet = addServlet(
ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
servlet.addInitParameter("fork", "false");
servlet.setLoadOnStartup(3);
servlet.setOverridable(true);
// Servlet mappings
ctx.addServletMapping("/", "default");
ctx.addServletMapping("*.jsp", "jsp");
ctx.addServletMapping("*.jspx", "jsp");
// Sessions
ctx.setSessionTimeout(30);
// MIME mappings
for (int i = 0; i < DEFAULT_MIME_MAPPINGS.length;) {
ctx.addMimeMapping(DEFAULT_MIME_MAPPINGS[i++],
DEFAULT_MIME_MAPPINGS[i++]);
}
// Welcome files
ctx.addWelcomeFile("index.html");
ctx.addWelcomeFile("index.htm");
ctx.addWelcomeFile("index.jsp");
}
示例2: setup
import org.apache.catalina.Context; //导入方法依赖的package包/类
@Before
public void setup() throws ServletException, LifecycleException, InterruptedException, JsonProcessingException {
webUITomcat = new Tomcat();
webUITomcat.setPort(3000);
webUITomcat.setBaseDir(testWorkingDir);
webUITomcat.enableNaming();
Context context = webUITomcat.addWebapp(CONTEXT, System.getProperty("user.dir") + File.separator + "src"
+ File.separator + "main" + File.separator + "webapp");
ContextEnvironment registryURL = new ContextEnvironment();
registryURL.setDescription("");
registryURL.setOverride(false);
registryURL.setType("java.lang.String");
registryURL.setName("registryURL");
registryURL.setValue("http://localhost:9001/tools.descartes.petsupplystore.registry/rest/services/");
context.getNamingResources().addEnvironment(registryURL);
webUITomcat.addServlet(CONTEXT, "servlet", getServlet());
webUITomcat.addServlet(CONTEXT, "index", new IndexServlet());
webUITomcat.addServlet(CONTEXT, "login", new LoginServlet());
webUITomcat.addServlet(CONTEXT, "order", new OrderServlet());
context.addServletMappingDecoded("/test", "servlet");
context.addServletMappingDecoded("/index", "index");
context.addServletMappingDecoded("/login", "login");
context.addServletMappingDecoded("/order", "order");
context.addWelcomeFile("/index");
webUITomcat.start();
// Mock registry
List<String> strings = new LinkedList<String>();
strings.add("localhost:9001");
String json = new ObjectMapper().writeValueAsString(strings);
wireMockRule.stubFor(get(urlEqualTo(
"/tools.descartes.petsupplystore.registry/rest/services/" + Service.IMAGE.getServiceName() + "/"))
.willReturn(okJson(json)));
wireMockRule.stubFor(get(urlEqualTo(
"/tools.descartes.petsupplystore.registry/rest/services/" + Service.STORE.getServiceName() + "/"))
.willReturn(okJson(json)));
wireMockRule.stubFor(get(urlEqualTo(
"/tools.descartes.petsupplystore.registry/rest/services/" + Service.PERSISTENCE.getServiceName() + "/"))
.willReturn(okJson(json)));
wireMockRule.stubFor(get(urlEqualTo(
"/tools.descartes.petsupplystore.registry/rest/services/" + Service.RECOMMENDER.getServiceName() + "/"))
.willReturn(okJson(json)));
// Mock images
HashMap<String, String> img = new HashMap<>();
img.put("andreBauer", "andreBauer");
img.put("johannesGrohmann", "johannesGrohmann");
img.put("joakimKistowski", "joakimKistowski");
img.put("simonEismann", "simonEismann");
img.put("norbertSchmitt", "norbertSchmitt");
img.put("descartesLogo", "descartesLogo");
img.put("icon", "icon");
mockValidPostRestCall(img, "/tools.descartes.petsupplystore.image/rest/image/getWebImages");
}