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#
全部评论

相关推荐

前端学习交流
点赞 评论 收藏
分享
一、部门介绍:-&nbsp;我们是抖音Feed&nbsp;团队,负责Feeds、播放器、双列、关注等抖音核心业务。业务流量巨大,工程复杂度高,对于架构设计、性能体验优化、稳定性保证都有很高的要求,欢迎喜欢挑战的你来参与二、优势:-&nbsp;核心部门-&nbsp;组内直招:合适直接发起面试(简单直接)(画重点)-&nbsp;个人会及时跟随进度,有情况随时可沟通三、岗位职责-&nbsp;负责抖音&nbsp;feeds&nbsp;研发,编写高质量的代码-&nbsp;和产品经理配合,深度参与手机产品需求讨论,功能定义等-&nbsp;设计良好的代码结构,不断迭代重构四、要求-&nbsp;计算机基础知识扎实,鸿蒙、iOS&nbsp;有无基础均可(有课程/mentor培养)其他:-&nbsp;2026届本科及以上学历在读,计算机、软件工程等相关专业优先-&nbsp;智能手机爱好者和使用者,追求良好的用户体验五、部门优势&amp;个人感受我们部门负责Feeds、播放器、双列、关注等抖音最核心业务。这里业务稳定,发展空间大:-&nbsp;既有Feeds、播放器等成熟产品方向需要持续深耕-&nbsp;又有双列这类承载抖音上限探索的重点方向需要我们一起突破;这里技术上也充满机会,业务流量巨大,工程复杂度高,对于架构设计、性能体验优化、稳定性保证都有很高的要求,欢迎喜欢挑战的你来参与这里团队梯度完备,技术氛围浓郁,且有系统完善的人才培养方案,相信一定能够给你的职业生涯开个好头,加速你的个人成长~~
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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