Tomcat7默认程序发布路径的使用与修改方法

2019-02-2520:06:40服务器及运维Comments2,714 views字数 1080阅读模式

tomcat7默认的程序发布路径为tomcat/webapps/ROOT/下面。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

例子文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

比如我在tomcat/webapps/ROOT/路径下新建一个jsp文件,则可以直接通过URL为:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

http://localhost:8080/index.jsp文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

来访问。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

再比如我做文件的上传和下载功能时,可以在ROOT下新建一个FileUpload文件夹,把上传文件的路径设为这个文件夹下,然后上传一个文件test.txt;做下载功能时,点击该文件的下载按钮,可以直接让网页打开一个URL:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

http://localhost:8080/FileUpload/test.txt文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

修改文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

打开tomcat/conf/server.xml,有如下代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

   <Host name="localhost" appBase="webapps"
      unpackWARs="true" autoDeploy="true">
    <!-- SingleSignOn valve, share authentication between web applications
       Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->
    <!-- Access log processes all example.
       Documentation at: /docs/config/valve.html
       Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
        prefix="localhost_access_log." suffix=".txt"
        pattern="%h %l %u %t "%r" %s %b" />
   </Host>

name为本地访问地址、appBase为项目的父地址,均可以修改。在host标签之间加入如下标签文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

<Context path="" docBase="example" debug="0" reloadable="true" />

其中path为虚拟目录的名字,只要输入IP地址就显示主页、docBase则为虚拟目录的路径,默认为tomcat/webapps/ROOT/,我们修改为 docBase=”example”,此时example就和ROOT的功能一样啦!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

mission success文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/9699.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/yunwei/9699.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定