配置虚似目录
来源:互联网 发布:在家编程赚钱 编辑:程序博客网 时间:2024/05/13 00:28
Web应用开发好后,若想供外界访问,需要把web应用交给web服务器管理,这个过程称之为配置虚似目录。
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!--表示管理C盘下的machinecat这个应用,通过浏览器访问的路径问http://ip:端口号/hn访问-->
<Context path=“/hn" docBase="d:\hainan" />
</Host>
注意:
tomcat5是不会自动把webapps下的应用映射成虚拟目录的,得手工配置;或者是webapps下的应用中有WEB-INF目录,WEB-INF目录下有web.xml文件,这样才能自动映射。
因为配置完虚拟目录还要重启服务器,这样重启期间很多东西都不能访问,所以不建议在server.xml下配置虚拟目录。
在Tomcat6中,不再建议在server.xml文件中配置context元素,细节查看tomcat服务器关于context元素的说明。
IE中打开http://localhost:8080/ ---> 点左边Documentation/Tomcat Documentation --->Reference/Configuration--->Containers/Context,看到有:
For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes
modifing the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.
Context elements may be explicitly defined:
•In the $CATALINA_BASE/conf/context.xml file: the Context element information will be loaded by all webapps.
•In the $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host.
•In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml extension) will be used as the context path. Multi-level context paths may be defined using #, e.g. foo#bar.xml for a context path of /foo/bar. The default web application may be defined by using a file called ROOT.xml.
•Only if a context file does not exist for the application in the $CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files. If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the application's context path. Once this file exists, it will not be replaced if a new WAR with a newer /META-INF/context.xml is placed in the host's appBase.
•Inside a Host element in the main conf/server.xml.
根据第二种方式,在apache-tomcat-6.0.20\conf\Catalina\localhost下新建一个任何名字的xml文件,比如confcontext.xml,里面写<Context docBase="d:\hainan" /> ,
那么访问http://localhost:8080/confcontext就能访问到此web应用。这样的改动是无需重启的。如果xml文件名为foo#bar.xml,那么访问路径为http://localhost:8080//foo/bar。
如果不制定访问路径,那么tomcat提供缺省的访问http://localhost:8080,也就是apache-tomcat-6.0.20\webapps\ROOT\index.html。
如果想将自己的应用配置成缺省web应用,那么confcontext.xml的名字改成ROOT,也就是ROOT.xml。把里面的某个文件映射成首页就能通过http://localhost:8080访问。到web应用/WEB-INF/web.xml中去配首页。
<welcome-file-list>
<welcome-file>xxx.html</welcome-file>
</welcome-file-list>
tomcat自带的例子中的web.xml文件没有配首页,也能缺省访问,这个是为什么呢?因为此web.xml继承了apache-tomcat-6.0.20\conf下的web.xml。
记住:配置某个web应用,都是通过"web应用/WEB-INF/web.xml"去配置的。
- 配置虚似目录
- tomcat目录配置
- Linux目录配置
- eclipse struts2 配置目录
- apache 目录服务 配置
- Linux目录配置
- linux目录配置 FHS
- VS2010 C++目录配置
- NFS共享目录配置
- Linux 目录配置 FHS
- VS2010 C++目录配置
- linux文件目录配置
- Nginx 配置目录访问
- vs2008项目目录配置
- vim 配置目录说明
- VS2010 C++目录配置
- linux的目录配置
- apache 配置共享目录
- Spring
- 定义函数areaZ,功能是求圆锥体积。在主函数中输入半径r和高h,调用函数areaZ求体积,并在主函数中输出圆锥体积,其中变量r,h均为double型数据。(公式:v=h*3.14*r2/3)
- 链表
- 原型模式
- eclipse, Log4j配置(真心的详细~)
- 配置虚似目录
- Linux内核:读写配置文件、/proc
- 的多少染发膏
- 前台技术--页面跳转的几种用法
- iOS 应用程序内部国际化,不跟随系统语言
- java Serializable 生成随机序列
- 各种软件读netcdf
- 8款世界级Webmail工具推荐
- 城市管理系统(LIstBox控件)