1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.getHost().setAutoDeploy(false);
StandardContext standardContext = new StandardContext();
standardContext.setPath("/sb");
standardContext.addLifecycleListener(new FixContextListener());
tomcat.addServlet("/sb", "helloword", new HelloServlet());
standardContext.addServletMappingDecoded("/hello", "helloword");
tomcat.start();
tomcat.getServer().await();
|