Tomcat之web应用的部署和网站目录的映射
来源:互联网 发布:psg1知乎 编辑:程序博客网 时间:2024/06/05 15:03
//注:$CATALINA_BASE表示Tomcat安装的目录,后面你会看到
//前半部分为分析,后半部分为实战
//CATALINA -->一个好听的名字:卡特琳娜
什么是web应用的部署和网站目录的映射?说白了就是如何让用户访问到我们开发的网站。
众所周知我么做好的网站都是放在某台服务器的某个硬盘的某个文件里面,
比如我开发了一个网站,将其放在了XXX服务器的E:\MyWeb文件夹下面
现在我想让别人访问到我的网站,该如何做呢?
在Tomcat 6.0.36的帮助文档里给出了详细的说明,
装好Tomcat后打开以下地址你就可以看到该文档了
http://localhost:8080/docs/config/context.html
//关于如何部署web应用和映射网站目录,Tomcat原文如下
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 modifying theContext configuration more invasive since the mainconf/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 calledROOT.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
.
With the exception of server.xml, files that define Context elements may only define a singleContext element.
//由以上可知Tomcat给了5种方法让我们配置web应用,这里我讲的是第三种,
//简单实用,无需重启Tomcat
//原文翻译如下
//在扩展名为.xml的档案文件,说的就是xml文件啦
In individual files (with a ".xml" extension)
//在Tomcat安装目录下的localhost文件夹
//如我的为 D:\Tomcat\Tomcat6.0.36\conf\Catalina\localhost
in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.
//文件名除去.xml后缀,将被用作web应用的路径
//何为context path? 比如我在localhost文件为ok.xml 则ok就是context path了
//用户打开网页的形式为http://XXX:8080/ok/123.html
//注:ok.xml里配有123.html的路径,如<context docBase="E:\Web"/>
//E:\Web里放着123.html
The name of the file (less the .xml extension) will be used as the context path.
//多级路劲用#号来定义,此时文件名形式为aaa#bbb#ccc.xml
//访问形式为http://XXX:8080/aaa/bbb/ccc/123.html
Multi-level context paths may be defined using #,
e.g. foo#bar.xml for a context path of /foo/bar.
//定义默认的网页应用建立ROOT.xml文件即可
//别忘了在ROOT.xml里设置网站的路径
The default web application may be defined by using a file called ROOT.xml.
//实战部分
1)我测试的网页放在E:\MyWeb下,截图如下
2)Tomcat安装在D:\Tomcat\Tomcat6.0.36 截图如下
3)进入localhost目录D:\Tomcat\Tomcat6.0.36\conf\Catalina\localhost
//在localhost目录下建立文件ok.xml 内容为<Context docBase="E:\MyWeb"/>
//截图如下
4)启动Tomcat,访问http://localhost:8080/ok/hello.html 即可
///附-->一种简单的访问web应用的方法
//将我们的web应用的整个目录拷贝到Tomcat安装目录下的webapps文件夹即可
//如将MyWeb拷贝到webapps
// 然后启动Tomcat 访问http://localhost:8080/MyWeb/hello.html即可
- Tomcat之web应用的部署和网站目录的映射
- Tomcat之web应用的部署和网站目录的映射
- Tomcat之web应用的部署和网站目录的映射
- 02tomcat--- web应用和虚似目录的映射.
- Tomcat的安装和部署web应用
- 关于tomcat的web目录映射问题
- web应用和虚似目录的映射
- web应用的虚拟目录映射和主机搭建(Tomcat)
- web应用的虚拟目录映射和主机搭建(Tomcat)
- JavaWeb学习篇之----web应用的虚拟目录映射和主机搭建(Tomcat)
- [置顶] JavaWeb学习篇之----web应用的虚拟目录映射和主机搭建(Tomcat)
- (Tomcat)服务器之web应用的虚拟目录映射和主机搭建
- Tomcat部署JSP网站(部署web应用?)
- Tomcat部署JSP网站(部署web应用?)
- Tomcat之web应用的目录组成结构
- 日常小结-tomcat结构目录、web应用及虚拟目录的映射
- java web应用访问tomcat目录外文件的路径映射问题
- tomcat部署web应用的方式
- onItemClick监听器四个arg参数
- type命令的用法
- 如何判断Framework4.0是否安装完整?
- Spring 使用注解方式进行事务管理
- hdu 5029 Relief grain (树链剖分+线段树)
- Tomcat之web应用的部署和网站目录的映射
- linux双机建立信任关系失败的解决方法
- ArcGIS教程:关于设置栅格捕捉选项
- Opencv各个版本的万能头文件
- Windows 64位操作系统安装mysql 绿色版 mysql安装常见问题(系统找不到指定的文件、发生系统错误 1067 进程意外终止)
- Log4j 配置详解
- 源码 反码 补码
- wamp 数据库连接出现错误 #2002
- 45 EL 表达式语言