[size=0.875]1 [size=0.875]2 | [size=0.875][size=0.875]<Context path="/projectOne " docBase="D:\projects\projectOne" [size=0.875]reloadable="true" /> |
[size=0.875]1 [size=0.875]2 [size=0.875]3 [size=0.875]4 [size=0.875]5 [size=0.875]6 [size=0.875]7 | [size=0.875][size=0.875]Tomcat tomcat = getTomcatInstance(); [size=0.875]File appDir = new File(getBuildDirectory(), "webapps/examples"); [size=0.875]tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath()); [size=0.875]tomcat.start(); [size=0.875]ByteChunk res = getUrl("http://localhost:" + getPort() + [size=0.875] "/examples/servlets/servlet/HelloWorldExample"); [size=0.875]assertTrue(res.toString().indexOf("<h1>Hello World!</h1>") > 0); |
[size=0.875]1 [size=0.875]2 [size=0.875]3 [size=0.875]4 [size=0.875]5 [size=0.875]6 [size=0.875]7 [size=0.875]8 [size=0.875]9 [size=0.875]10 [size=0.875]11 [size=0.875]12 [size=0.875]13 [size=0.875]14 [size=0.875]15 [size=0.875]16 [size=0.875]17 [size=0.875]18 [size=0.875]19 [size=0.875]20 | [size=0.875][size=0.875]public Context addWebapp(Host host, String url, String path) { [size=0.875] silence(url); [size=0.875] Context ctx = new StandardContext(); [size=0.875] ctx.setPath( url ); [size=0.875] ctx.setDocBase(path); [size=0.875] if (defaultRealm == null) { [size=0.875] initSimpleAuth(); [size=0.875] } [size=0.875] ctx.setRealm(defaultRealm); [size=0.875] ctx.addLifecycleListener(new DefaultWebXmlListener()); [size=0.875] ContextConfig ctxCfg = new ContextConfig(); [size=0.875] ctx.addLifecycleListener(ctxCfg); [size=0.875] ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML"); [size=0.875] if (host == null) { [size=0.875] getHost().addChild(ctx); [size=0.875] } else { [size=0.875] host.addChild(ctx); [size=0.875] } [size=0.875] return ctx; [size=0.875]} |
[size=0.875]1 [size=0.875]2 [size=0.875]3 [size=0.875]4 [size=0.875]5 [size=0.875]6 [size=0.875]7 [size=0.875]8 [size=0.875]9 [size=0.875]10 [size=0.875]11 [size=0.875]12 [size=0.875]13 [size=0.875]14 [size=0.875]15 [size=0.875]16 [size=0.875]17 [size=0.875]18 [size=0.875]19 [size=0.875]20 [size=0.875]21 [size=0.875]22 [size=0.875]23 [size=0.875]24 [size=0.875]25 [size=0.875]26 [size=0.875]27 [size=0.875]28 [size=0.875]29 [size=0.875]30 [size=0.875]31 [size=0.875]32 [size=0.875]33 [size=0.875]34 [size=0.875]35 [size=0.875]36 [size=0.875]37 [size=0.875]38 [size=0.875]39 [size=0.875]40 [size=0.875]41 [size=0.875]42 [size=0.875]43 [size=0.875]44 [size=0.875]45 [size=0.875]46 [size=0.875]47 [size=0.875]48 | [size=0.875][size=0.875]for (ServletDef servlet : servlets.values()) { [size=0.875] Wrapper wrapper = context.createWrapper(); [size=0.875] String jspFile = servlet.getJspFile(); [size=0.875] if (jspFile != null) { [size=0.875] wrapper.setJspFile(jspFile); [size=0.875] } [size=0.875] if (servlet.getLoadOnStartup() != null) { [size=0.875] wrapper.setLoadOnStartup(servlet.getLoadOnStartup().intValue()); [size=0.875] } [size=0.875] if (servlet.getEnabled() != null) { [size=0.875] wrapper.setEnabled(servlet.getEnabled().booleanValue()); [size=0.875] } [size=0.875] wrapper.setName(servlet.getServletName()); [size=0.875] Map<String,String> params = servlet.getParameterMap(); [size=0.875] for (Entry<String, String> entry : params.entrySet()) { [size=0.875] wrapper.addInitParameter(entry.getKey(), entry.getValue()); [size=0.875] } [size=0.875] wrapper.setRunAs(servlet.getRunAs()); [size=0.875] Set<SecurityRoleRef> roleRefs = servlet.getSecurityRoleRefs(); [size=0.875] for (SecurityRoleRef roleRef : roleRefs) { [size=0.875] wrapper.addSecurityReference( [size=0.875] roleRef.getName(), roleRef.getLink()); [size=0.875] } [size=0.875] wrapper.setServletClass(servlet.getServletClass()); [size=0.875] MultipartDef multipartdef = servlet.getMultipartDef(); [size=0.875] if (multipartdef != null) { [size=0.875] if (multipartdef.getMaxFileSize() != null && [size=0.875] multipartdef.getMaxRequestSize()!= null && [size=0.875] multipartdef.getFileSizeThreshold() != null) { [size=0.875] wrapper.setMultipartConfigElement(new [size=0.875]MultipartConfigElement( [size=0.875] multipartdef.getLocation(), [size=0.875] Long.parseLong(multipartdef.getMaxFileSize()), [size=0.875] Long.parseLong(multipartdef.getMaxRequestSize()), [size=0.875] Integer.parseInt( [size=0.875] multipartdef.getFileSizeThreshold()))); [size=0.875] } else { [size=0.875] wrapper.setMultipartConfigElement(new [size=0.875]MultipartConfigElement( [size=0.875] multipartdef.getLocation())); [size=0.875] } [size=0.875] } [size=0.875] if (servlet.getAsyncSupported() != null) { [size=0.875] wrapper.setAsyncSupported( [size=0.875] servlet.getAsyncSupported().booleanValue()); [size=0.875] } [size=0.875] context.addChild(wrapper); [size=0.875]} |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |