Tomcat默认程序发布路径的使用与修改方法讲解
今天小编就为大家分享一篇关于Tomcat默认程序发布路径的使用与修改方法讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
tomcat7默认的程序发布路径为tomcat/webapps/ROOT/下面。
例子
比如我在tomcat/webapps/ROOT/路径下新建一个jsp文件,则可以直接通过URL为:
来访问。
再比如我做文件的上传和下载功能时,可以在ROOT下新建一个FileUpload文件夹,把上传文件的路径设为这个文件夹下,然后上传一个文件test.txt;做下载功能时,点击该文件的下载按钮,可以直接让网页打开一个URL:
修改
打开tomcat/conf/server.xml,有如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < 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标签之间加入如下标签
1 | < Context path = "" docBase = "example" debug = "0" reloadable = "true" /> |
其中path为虚拟目录的名字,只要输入IP地址就显示主页、docBase则为虚拟目录的路径,默认为tomcat/webapps/ROOT/,我们修改为 docBase=”example”,此时example就和ROOT的功能一样啦!
mission success
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值