Tomcat

Tomcat

下载

Apache Tomcat® - Apache Tomcat 9 Software Downloads

安装

解压,将文件夹移动到自己想要的路径

环境变量配置(不是必须的,配置只是为了命令行可以直接执行startup.bat等脚本)

环境变量->系统变量->新建

变量名CATALINA_HOME 变量值path\to\apache-tomcat-9.0.100

Path变量新增项:%CATALINA_HOME%\bin

Tomcat配置

conf/server.xml

<!-- 端口配置(默认为8080)、协议、超时时长、重定向端口、最大参数数量 -->
<Connector port="8099" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           maxParameterCount="1000"
           />

<!-- 默认绑定主机名、应用所在目录、是否解包war、是否自动部署 -->
<!-- 此处的主机名需要与主机中定义的主机名一致,例如windows下 C:\Windows\System32\drivers\etc\hosts 文件中设置的主机名 -->
<!-- 修改如下 -->
# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
127.0.0.1		ssydx
<!-- 此时该处的name也应设置为ssydx -->
<Host name="ssydx"  appBase="webapps"
      unpackWARs="true" autoDeploy="true">
    
<!-- 最终本地访问为ssydx:8099 -->

webapps/ROOT/index.jsp

<!-- 未添加应用是默认访问ROOT应用、index.jsp就是其主页 -->

发布应用

复制一份ROOT修改名称,删除除WEB-INF之外的内容

/webapps/webappname/WEB-INF/web.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

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  version="4.0"
  metadata-complete="true">

</web-app>

新建/webapps/webappname/index.html

<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>SSYDX</title>
</head>
<body>
    <h1>这是首页</h1>
    <p>Hello world</p>
    <a href="./other.html">去另一页</a>
</body>
</html>

新建/webapps/webappname/other.html

<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>SSYDX</title>
</head>
<body>
    <h1>这是另一页</h1>
    <p>Hello ssydx</p>
    <a href="./index.html">去首页</a>
</body>
</html>

启动Tomcat

双击执行/bin/startup.bat或/bin/startup.sh

在浏览器输入localhost:8099会访问ROOT应用

在浏览器输入localhost:8099/webappname会访问webappname应用

默认显示的是index页面

其他文件夹

文件夹名称 内容
examples 一些应用样例
host-manager 主机管理,提供可视化界面进行设置,需要设置用户信息,在/conf/tomcat-users.xml文件中
manager 应用管理,提供可视化界面进行设置,需要设置用户信息,在/conf/tomcat-users.xml文件中
docs tomcat的帮助文档
#java##tomcat##javaweb#
全部评论

相关推荐

“无名小卒,还是名扬天下?”我知道很多人都不觉得我能走到今天这一步,当然,也包括我自己。在我的人生里,有两部作品刻下了最深的烙印:《斗破苍穹》与《龙族》。它们总被人拿来对照:一边是萧炎的桀骜轻狂,一边是路明非的怯懦衰颓。有人说,天蚕土豆没见过魂天帝,但江南见过真凯撒。我时常觉得,自己就是那个衰小孩路明非。可路明非可以开挂,我不可以;我也无数次幻想过,能拥有萧炎那般年少轻狂的人生,可我没有他与生俱来的逆天天赋。我只是个平庸的普通人,一个看过《斗破苍穹》却开不了挂的路明非,只能一步一步往上爬。从我下定决心找实习的那一刻起,我就给自己定下了目标:“我一定要为字节跳动卖命.jpg”。萧炎有他的三年之约,我有我的两年半之约(其实是一年半)。2024.11.20,科大讯飞的第一封实习offer落进邮箱,我迈出了这场奔赴的第一步。2025.8.18,放弃百度转正的安稳机会,转身走进前路未卜的不确定里。我很感谢我在百度的mentor,是她从茫茫人海选中了我,给了我大厂实习的机会。即便有段时间我状态差、产出不理想,她依旧愿意认可我、希望我留下转正。2025.11.14,我选择走进字节跳动,以实习生的身份重新出发。2026.3.25&nbsp;-&nbsp;3.31,一周速通上海飞书,幸遇赏识我的伯乐,斩获Special&nbsp;Offer。被告知面试通过的那一刻,我的内心无比平静,就像这个offer本就该属于我。不是侥幸,是应得的。这一路,有人看轻过我的出身,不相信我能走到这里;也有人在我看不见前路的时候,替我举过灯。没有他们的鼓励与支撑,就没有今天站在这里的我。我看到了自强不息的激荡,那是一个双非的伟大乐章!我是雨夜迈巴赫,我要开启属于我的新篇章了。
在看牛客的本杰明很勇...:真心祝贺l总 我永远的偶像 我滴神
春招至今,你收到几个面试...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务