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

相关推荐

点赞 评论 收藏
分享
真tmd的恶心,1.面试开始先说我讲简历讲得不好,要怎样讲怎样讲,先讲背景,再讲技术,然后再讲提升多少多少,一顿说教。2.接着讲项目,我先把背景讲完,开始讲重点,面试官立即打断说讲一下重点,无语。3.接着聊到了项目的对比学习的正样本采样,说我正样本采样是错的,我解释了十几分钟,还是说我错的,我在上一家实习用这个方法能work,并经过市场的检验,并且是顶会论文的复现,再怎么不对也不可能是错的。4.面试官,说都没说面试结束就退出会议,把面试者晾在会议里面,丝毫不尊重面试者难受的点:1.一开始是讲得不好是欣然接受的,毕竟是学习。2.我按照面试官的要求,先讲背景,再讲技术。当我讲完背景再讲技术的时候(甚至已经开始蹦出了几个技术名词),凭什么打断我说讲重点,是不能听出人家重点开始了?这也能理解,每个人都有犯错,我也没放心上。3.我自己做过的项目,我了解得肯定比他多,他这样贬低我做过的项目,说我的工作是错误的,作为一个技术人员,我是完全不能接受的,因此我就和他解释,但无论怎么解释都说我错。凭什么,作为面试官自己不了解相关技术,别人用这个方式work,凭什么还认为这个方法是错的,不接受面试者的解释。4.这个无可厚非,作为面试官,不打招呼就退出会议,把面试者晾着,本身就是有问题。综上所述,我现在不觉得第一第二点也是我的问题,面试官有很大的问题,就是专门恶心人的,总结面试官说教,不尊重面试者,打击面试者,不接受好的面试者,技术一般的守旧固执分子。有这种人部门有这种人怎么发展啊。最后去查了一下,岗位关闭了。也有可能是招到人了来恶心人的,但是也很cs
牛客20646354...:招黑奴啊,算法工程师一天200?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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