String webBase = new File("src/main/webapp").getAbsolutePath();
Tomcat tomcat = new Tomcat();
tomcat.setPort(9002);
tomcat.setBaseDir(".");
StandardServer server = (StandardServer) tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
Context webContext = tomcat.addWebapp("/", webBase);
ErrorPage notFound = new ErrorPage();
notFound.setErrorCode(404);
notFound.setLocation("/index.html");
webContext.addErrorPage(notFound);
webContext.addWelcomeFile("index.html");
tomcat.start();
tomcat.getServer().await();
embedded tomcat
最新推荐文章于 2022-08-02 03:24:15 发布