提示:
Tomcat使用知识
一、怎么运行 tomcat:
1、打开文件夹:tomcat->bin
运行startup.sh文件(终端窗口会自动关闭)
提示:Window10是运行startup.bat(终端窗口不会关闭)
Shotdown两个文件是关闭服务器。
2、浏览器打开:localhost:8080
即可进入tomcat官网 即表示已经已成功运行tomcat
换行
二、假如我要运行自己的项目:
1、 将war包项目放入tomcat文件夹:tomcat->webapps
2、按上面的怎么运行tomcat来一遍,浏览器输入:
http://localhost:8080/todo1-1.0-SNAPSHOT/index.html
即可访问你的项目
提示: todo1-1.0-SNAPSHOT是你的项目的名字
三、War项目怎么来(举个gradle项目的例子,其他的看情况):
1、写好页面(html或jsp等)
2、按图片来
3、结果
四、一个tomcat部署多个项目、多个域名
1、打开文件:tomcat->conf->server.xml
<Host name="aaa.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="ROOT" debug="0" reloadable="true"/>
</Host>
<Host name="bbb.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="Flower" debug="0" reloadable="true"/>
</Host>
这里表示通过 aaa.com 可以访问 webapps 文件夹下的 ROOT 项目 ,默认打开index.html 或者 index.htm 、index.jsp 文件
通过 bbb.com 可以访问 webapps 文件夹下的 Flower 项目 ,默认打开index.html 或者 index.htm 、 index.jsp 文件
五、修改tomcat默认打开的文件,index.html
1、打开文件:tomcat->conf->web.xml
<welcome-file-list><!-- 默认打开的页面 -->
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>首页/首页.html</welcome-file>
<welcome-file>首页.html</welcome-file>
</welcome-file-list>
结合第四步: aaa.com 可以默认访问ROOT文件夹下的 首页.html,如果有下一层文件夹也可以访问,比如打开aaa.com时,默认访问的是:ROOT/首页/首页.html