tomcat下载与使用教程

1. tomcat下载

官网:https://tomcat.apache.org/
tomcat下载与使用教程_第1张图片

镜像地址:https://mirrors.huaweicloud.com/apache/tomcat/
1、选择一个版本下载,官网下载速度缓慢,推荐镜像
2、对压缩包进行解压,无需进行安装,解压放置一个位置,以后不挪动。
tomcat下载与使用教程_第2张图片

2. 配置环境变量

1、新建系统变量
变量名:CATALINA_HOME
变量值:tomcat路径
tomcat下载与使用教程_第3张图片
2、加入Path
tomcat下载与使用教程_第4张图片

3. tomcat启动

1、win+R打开cmd,输入startup,之后弹出一个窗口,不要关闭
tomcat下载与使用教程_第5张图片
2、浏览器输入localhost:8080/
tomcat下载与使用教程_第6张图片
成功!

4. IDEA配置tomcat

1、右上角->Edit Configuration
tomcat下载与使用教程_第7张图片2、Tomcat Server -> Local
tomcat下载与使用教程_第8张图片
3、配置Tomcat路径:Configure - > OK
tomcat下载与使用教程_第9张图片
4、配置JRE路径
tomcat下载与使用教程_第10张图片
5、Deployment -> +
tomcat下载与使用教程_第11张图片
至此,IDEA配置Tomcat便完毕!

5. IDEA测试Tomcat使用

写一个简单的测试程序,代码结构如下:
tomcat下载与使用教程_第12张图片
Person.java

package com.atguigu.demo;

public class Person {
    public String getName() {
        return "tom";
    }
}

index.jsp

<%@ page import="com.atguigu.demo.Person" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
</head>
<body>
<%=new Person().getName() %>
</body>
</html>

web.xml


<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">
web-app>

运行代码
在这里插入图片描述
之后弹出页面
tomcat下载与使用教程_第13张图片
成功!

你可能感兴趣的:(#,maven,tomcat,java)