Tomcat发布项目的三种方式

需求: 如何能让其他的电脑访问我这台电脑上的资源 ? stu.xml

拷贝这个文件到webapps/ROOT底下, 在浏览器里面访问。

http://localhost:8080/stu.xml

在webaps下面新建一个文件夹xml , 然后拷贝文件放置到这个文件夹中
http://localhost:8080/xml/stu.xml
http://localhost:8080 : 对应的是到webapps/root
http://localhost:8080/xml/ : 对应是 webapps/xml
使用IP地址访问:http://本机ip:8080/xml/stu.xml

配置虚拟路径 1

使用localhost:8080 打开tomcat首页, 找到Tomcat 8.5 Documentation,进入Reference,点击configuration ,找到左边的context,点击进入,复制此页面路径:

http://localhost:8080/docs/config/context.html

在这里插入图片描述

  • 在conf/server.xml 找到host元素节点。加入以下内容。
    在这里插入图片描述
  • 在浏览器地址栏上输入: http://localhost:8080/daq/person.xml

配置虚拟路径2

  1. 在tomcat/conf/catalina/localhost/ 文件夹下新建一个xml文件,名字可以自己定义。 person.xml

  2. 在这个文件里面写入以下内容

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="F:\XML2"></Context>
  1. 在浏览器上面访问:
 http://localhost:8080/person/xml的名字即可
发布了61 篇原创文章 · 获赞 53 · 访问量 9178

猜你喜欢

转载自blog.csdn.net/weixin_44861399/article/details/104493164