Tomcat虚拟目录设置

来源:互联网 发布:碱性食物 知乎 编辑:程序博客网 时间:2024/05/15 12:27
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Tomcat 安装好之后,只需要把你的程序包放到$Tomcat_Home$/webapps下就可以直接使用了。这样会使webapps越来越大就需要设置虚拟目录:
1.单个应用设置:
 在<Host>和</host>之间加上
 <Context path="/site" docBase="d:site" reloadable="true" debug="0">
 </Context>
 参数:path 表示在浏览器中输入http://localhost:8080/site
     docBase表示你的程序包的物理绝对路径,默认的绝对路径是$Tomcat_Home$/webapps
 这样设定了之后会在$Tomcat_home$/conf/catalina/localhost目录下生成一个site.xml文件,此文件的内容就是刚才设置的内容。
2.通过前面我们知道了在$Tomcat_home$/conf/catalina/localhost目录下会生成相应的配置文件,因此我们可以直接在$Tomcat_home$/conf/catalina/localhost目录下写配置文件文件名任意取,最好是跟你的web应用相同便于管理,如site.xml内容同上
<Context path="/site" docBase="d:site" reloadable="true" debug="0">
 </Context>
3.更改整个根目录:
  找到<Host name="localhost" debug="0" appBase="webapps"
  unpackWARs="true" autoDeploy="true">
 将appBase的设置成期望的路径(绝对路径)
 出现的问题:输入:http://localhost:8080/没有出现默认的页面
 原因当然是更改了路径造成的。解决也很简单了,把文件拷过来,或者再把原来默认的设成虚拟路径。<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击