新手提问,关于内嵌tomcat启动正常,访问jsp报404找不到resource
url : http://localhost:8898/studyPro/index.jsp
The requested resource (/studyPro/index.jsp) is not available.
load context log :
appPath:/studyPro
装载了Web应用studyPro
appPath:
装载了Web应用ROOT
init code:
private void init() throws UnknownHostException {tomcat.setCatalinaHome(catalinaHome);Engine engine = tomcat.createEngine();engine.setName(engineName);Host host = tomcat.createHost("localhost", tomcat.getCatalinaHome()+ appBase);host.setAutoDeploy(true);if (logger.isInfoEnabled()) {logger.info("WebApp的根路径为" + appBase);}File baseDir = new File(tomcat.getCatalinaHome() + appBase);// 自动获取webapps下的war,就行解压和自动获取创建Contextif (baseDir.exists()) {chkAndExtractWar(baseDir);File lstFile = new File(baseDir, "webapps.lst");// deploy文件jspif (lstFile.exists()) {lstDeploy(host, baseDir);} else {defaultDeploy(host, baseDir);}}engine.setDefaultHost(host.getName());engine.addChild(host);tomcat.addEngine(engine);tomcat.setDebug(logLever);InetAddress ias = InetAddress.getByName("0.0.0.0");Connector connector = tomcat.createConnector(ias, port, false);if (connector instanceof CoyoteConnector) {CoyoteConnector cconnector = (CoyoteConnector) connector;cconnector.setURIEncoding("GBK");}tomcat.addConnector(connector);if (logger.isInfoEnabled()) {logger.info("创建连接器" + ias.getHostAddress() + ":" + port);}}
FileFilter appDirFF=new FileFilter(){ public boolean accept(File pathname) { if( pathname.isDirectory()){ //目录下必须有WEB-INF和WEB-INF/web.xml File webInf=new File(pathname,"WEB-INF"); return webInf.exists() && new File(webInf,"web.xml").exists(); } return false; } }; //获取所有的目录,转换成Context并加载 File[] appDirs=baseDir.listFiles(appDirFF); for (int i = 0; i < appDirs.length; i++) { String appDirName=appDirs[i].getName(); String appPath="/"+appDirName; if("ROOT".equalsIgnoreCase(appDirName)){ appPath=""; } Context ctxRoot = tomcat.createContext(appPath,appDirName); ctxRoot.setPrivileged(true); ctxRoot.setReloadable(true); ctxRoot.addParameter("debug", "0"); host.addChild(ctxRoot); if(logger.isInfoEnabled()) { logger.info("装载了Web应用"+appDirName); } }