在tomcat源码ExpandWar.java类源码中有这么几句代码:
public static String expand(Host host, URL war, String pathname)
throws IOException{
...
File docBase = new File(appBase, pathname);
if (docBase.exists()) {
// War file is already installed
return (docBase.getAbsolutePath());
}
...
//解析war包;
...
return docBase.getAbsolutePath();
}
代码解释:
1,docBase表示tomcat的webapps/下的某个应用,例如对于test_war.war这个war包说
docBase就是E:\tomcat\webapps\test_war目录的file实例,
即就是 docBase = new File(new File("E:\tomcat\webapps"),"test_war");
2,上述代码的红色部分是判断该E:\tomcat\webapps\test_war路径是否存在,如果存在则返回该路径,而不进行下面的解压war包的代码;
综上如果将test_war.war包放到webapps目录中,然后再在webapps文件夹中创建一个test_war文件夹则,启动tomcat之后test_war文件夹仍然为空,没有达到完整部署项目的目的,仍然访问不到项目,所以,这个应该是tomcat的一个需要改进或是说修改的地方吧。