zoukankan      html  css  js  c++  java
  • tomcat之虚拟目录

    一般我们都是直接引用webapps下面的web项目,如果我们要部署一个在其它地方的WEB项目,这就要在TOMCAT中设置虚拟路径了,Tomcat的加载web顺序是先加载 $Tomcat_home$confCatalinalocalhost下面的xml文件(文件中配置了web项目所在路径),然后再加载webapps下的web项目.

    方法一: 在$Tomcat_home$confCatalinalocalhost路径下新建一个XML文件,注意:XML文件的名字也就是项目部署成功后的web根路径.假如定义这test.xml,那么后面的访问路径就是http://ip:port/test,文件内容如下:(我的项目文件夹/root/bp下,这种方法不用重启tomcat)

    [root@localhost localhost]# pwd
    /root/apache-tomcat-7.0.91/conf/Catalina/localhost
    [root@localhost localhost]# ls
    bp.xml
    [root@localhost localhost]# cat bp.xml 
    <?xml version="1.0" encoding="UTF-8"?>
    <Context docBase="/root/bp"  reloadable="true"  debug="0"/>
    [root@localhost localhost]# curl 172.16.1.110:8080/bp/   #有点奇怪,如果bp后不加/会访问不到
    this is a test!
    [root@localhost localhost]# cat /root/bp/index.html 
    this is a test!
    [root@localhost localhost]# 
    

    方法二:编辑server文件(%tomcathome%confserver.xml)
    我们打算建立一个myjsp的虚拟目录,只要在%tomcathome%confserver.xml文件,在<host>标签中(一般在最后几行附近)加入文件中加入如下代码即可:(需要重启tomcat)

    [root@localhost localhost]# cat /root/second/index.html 
    this is second virtual dir
    [root@localhost localhost]# grep second /root/apache-tomcat-7.0.91/conf/server.xml 
    	<Context docBase="/root/second"  reloadable="true"  debug="0" path="/second"/>
    [root@localhost localhost]#ps -ef|grep java
    root      2966     1  0  2018 ?        01:08:55 /usr//java/jdk1.8.0_102/jre/bin/java -Djava.util.logging.config.file=/root/apache-tomcat-7.0.91/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dignore.endorsed.dirs= -classpath /root/apache-tomcat-7.0.91/bin/bootstrap.jar:/root/apache-tomcat-7.0.91/bin/tomcat-juli.jar -Dcatalina.base=/root/apache-tomcat-7.0.91 -Dcatalina.home=/root/apache-tomcat-7.0.91 -Djava.io.tmpdir=/root/apache-tomcat-7.0.91/temp org.apache.catalina.startup.Bootstrap start
    root     15383 15055  0 15:53 pts/0    00:00:00 grep --color=auto java
    [root@localhost localhost]# kill -9 2966
    [root@localhost localhost]# /root/apache-tomcat-7.0.91/bin/startup.sh
    [root@localhost localhost]# curl 172.16.1.110:8080/second/
    this is second virtual dir
    [root@localhost localhost]#
    

      

  • 相关阅读:
    梯度方向问题
    switchsharp
    R语言学习笔记:sort、rank、order、arrange排序函数
    R语言学习笔记:choose、factorial、combn排列组合函数
    MySQL学习笔记:少用Null
    Oracle学习笔记:11g服务介绍及哪些服务必须开启?
    GreenPlum学习笔记:create or replace function创建函数
    Python学习笔记:出生日期转化为年龄
    Python学习笔记:import sys模块(argv、path、platform、exit)
    Oracle学习笔记:wm_concat函数合并字段
  • 原文地址:https://www.cnblogs.com/biaopei/p/10401642.html
Copyright © 2011-2022 走看看