java
专栏收录该内容
15 篇文章0 订阅
订阅专栏
欢迎访问个人在线工具类网站:https://www.ctools.top
我们以tomcat为例通过输入域名直接访问项目首页的配置方法。我的域名为:www.ctools.top,也欢迎大家访问。
第一步:申请一个域名并做好DNS域名解析,或者本地修改host域名指向。域名指向的修改方法为:
在hosts文件最后一行添加:127.0.0.1 www.ctools.top
第二步,将index.html设置项目的默认首页,修改项目的web.xml文件
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
第三步:将tomcat访问端口号更改为 80,更改后可以通过访问www.ctools.top 查看是否访问到猫的界面。
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" />
第四步:将Engine标签下的defaultHost更改为你设置的域名。
<Engine name="Catalina" defaultHost="www.ctools.top">
第五步:更改<Host></Host>标签下的name值为访问的域名。
<Host name="www.ctools.top" appBase="webapps"
unpackWARs="true" autoDeploy="true">
第六步:在</Host>标签前添加<Context docBase="ctools" path="" reloadable="true" />。其中docBase为需要访问的项目名称。
<Context docBase="ctools" path="" reloadable="true" />
到此配置完成。可以重新启动tomcat输入域名测试。直接在浏览器中访问你的域名即可。
完整的tomcat配置文件server.xml内容如下:
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at<