Tomcat Notes: URL Mapping
This is a personal study notes of Apache Tomcat. Below are main reference material.
- YouTube Apache Tomcat Full Tutorial,owed by Alpha Brains Courses. https://www.youtube.com/watch?v=rElJIPRw5iM&t=801s
- 1、URL Mapping To Resources
- 1.1、What we request for when hitting a URL
- 1.2、Mapping Code
- 1.2.1、Mapping To Resources
- 1.2.1.1、Access Resourses in ROOT
- 1.2.2、Mapping To Service
1、URL Mapping To Resources
1.1、What we request for when hitting a URL
When we hit a URL on browser like localhost:8080/example/hellowe are actually reqeusting a resource or service.
Resource refer to a file like .html,.image. For example when we hit example root full path which is localhost:8080/example, we are requesting index.htmland this file will be explained and rendered by browser and showed in a readable way.
I perceive those static files as a kind of resource.
But sometims we only request a service rather than a static file.
For example we click a buttton then browser sends a http request, supposing it’s URL is https://www.system.com/delete?id=1.
A Tomcat application recieve the request and provide service which is deleting a record in database.
This is requesting for a servcie.
1.2、Mapping Code
Mapping to a resource is easy. It usually is like access file system.
But mapping to a service is more tricky.
I’m going to show how Tomcatmapping URL to a resource or service.
Supposing our web application’s root URL is localhost:8080/myweb/
we have a war file like below. I omit some files for readability.
myweb.war
----index.html
----assets
--------hello.img
----WEB-INF
---------web.xml
---------classes
-------------HelloServlet.class
----META-INF
1.2.1、Mapping To Resources
As i mentioned, mapping URL to a resource basically is similar to accessing a file in file system.
For example, If we want to get index.html, just call localhost:8080/myweb/index.html.
If wanting hello.img, just call localhost:8080/myweb/assets/hello.img.
So it’s very similiar to file system.
Just notice that web root URL localhost:8080/myweb/represents hello.war’s first level subdirectory. Then you can get all static resources hierarchyly just as the same way in file system.
1.2.1.1、Access Resourses in ROOT
Tomcat can have mutiple web applications which are located under webappsfolder.
webapps
----myweb
----myweb1
----myweb2
----ROOT
---------root.txt
What I just showed is how to access static resources in myweb.
If accessig files in myweb, we should take localhost:8080/mywebas root URL.
If accessig files in myweb1, we should take localhost:8080/myweb1as root URL.
So mywebor myweb1is context which specifies which web apps you want to access.
Besides those web applicaton developed by programmer, Tomcatalways has a folder called ROOTunder webapps.
If you want to access static resources under ROOT, root.txtfor example, just remove the context and take localhost:8080/as the root URL representig the first level subdirectory of ROOT.
Thus just call localhost:8080/root.txtthen you can get root.txt.
1.2.2、Mapping To Service
Mapping URL to service could be more tricky. Because Java servlet classes usually have more deeper file structure, making URL too long.
com.org.servlet.MyServlet.java # It has 4 levels directory in total
acme.personnel.management.MedicalPlan # very long
For readability Tomcat has a configuration file called web.xmlto map to resources with a more simple name.
Supposing we have a servlet called DeleteRecordServletwhose doGetmethod is to delete a record in database, whose location is myweb.war/com/org/servlet/DeleteRecordServlet.java.
myweb.war # omit some files
----com
--------org
------------servlet
----------------DeleteRecordServlet.java
----META-INF
--------web.xml
--------classes
------------com
----------------org
--------------------servlet
------------------------DeleteRecordServlet.class
Now we need to configure some mapping in web.xml, mapping a shorter url to DeleteRecordServlet.
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<web-app><servlet><servlet-name>deleteServlet</servlet-name><servlet-class>com.org.servlet.DeleteRecordServlet</servlet-class></servlet><servlet-mapping><servlet-name>deleteServlet</servlet-name><url-pattern>/delete</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.html</welcome-file></welcome-file-list>
</web-app>
In this way we can hit localhost:8080/myweb/deletewhich is more simple than normal url to call DeleteRecordServlet.
相关文章:
Tomcat Notes: URL Mapping
This is a personal study notes of Apache Tomcat. Below are main reference material. - YouTube Apache Tomcat Full Tutorial,owed by Alpha Brains Courses. https://www.youtube.com/watch?vrElJIPRw5iM&t801s 1、URL Mapping To Resources1.1、What w…...
【JVM】JVM概述
JVM概述 基本介绍 JVM:全称 Java Virtual Machine,即 Java 虚拟机,一种规范,本身是一个虚拟计算机,直接和操作系统进行交互,与硬件不直接交互,而操作系统可以帮我们完成和硬件进行交互的工作特…...
【2023开发组二等奖】湖南省国土空间规划双评价系统
作品介绍 1 需求分析 1.1 背景与意义 在我国辽阔的国土空间中,各地区的地形地势、自然条件和资源环境禀赋存在显著差异。然而,随着人口增长和城市化进程加快,高强度的不合理开发和产业布局广泛分布,使得部分地区的经济社会发展规模超过了资源环境的承载能力。因此,执行主…...
Flutter为什么不需要子线程——Dart IO源码剖析(上)
Dart IO 源码剖析 许多Flutter新手,特别是安卓、iOS原生开发转做Flutter的小伙伴,一直对Flutter 单线程模型开发APP倍感不解,他们总是喜欢本能的把网络请求、文件读写放到一个单独线程去做,因为“耗时操作会阻塞UI线程嘛”。于是…...
docker使用Dockerfile制做容器(以hyperf为列,开机启动)
1、Dockerfile文件 FROM hyperf/hyperf:8.1-alpine-v3.18-swoole WORKDIR /data MAINTAINER dade <dadeqq.com> ADD start.sh start.sh RUN chmod x ./start.sh CMD /data/start.sh1-1、执行命令生成hyperf:latest容器(文件名是Dockerfile可以省略࿰…...
PDF转PowerPoint - Java实现方法
通过编程实现PDF转PPT的功能,可以自动化转换过程,减少手动操作的工作量,并根据需要进行批量转换。将PDF文件转换为PPT文档后,可以利用PPT的丰富功能和动画效果,达到更好的演示效果。 在Java中,我们可以使用…...
【Spring之手写一个依赖注入容器】
Spring之手写一个依赖注入容器 1. 创建两个自定义注解1.1 Component注解1.2 DI注解 2. ApplicationContext接口与实现类2.1 ApplicationContext 接口2.2 实现类:DefaultListableApplicationContext 3. 定义DAO层和Service层及其实现4. 定义异常信息类4.1 InjectBean…...
kafka之java客户端实战
1. kafka的客户端 Kafka提供了两套客户端API,HighLevel API和LowLevel API。 HighLevel API封装了kafka的运行细节,使用起来比较简单,是企业开发过程中最常用的客户端API。 而LowLevel API则需要客户端自己管理Kafka的运行细节,Pa…...
图解渠道网关:不只是对接渠道的接口(一)
这是《百图解码支付系统设计与实现》专栏系列文章中的第(20)篇。点击上方关注,深入了解支付系统的方方面面。 主要讲清楚什么是渠道,有哪些类型的渠道,什么是渠道网关,渠道网关在支付系统中定位、核心功能…...
【js版数据结构学习之队列】
队列 一、简要认识队列二、队列的封装三、队列的应用1.栈和队列的转换2.全排列3.任务调度4.缓存管理 一、简要认识队列 结构:一种特殊的线性表 入队:在队尾插入一个元素 出队:在队头删除一个元素 特点:先入先出 空队列࿱…...
iOS Xcode 升级Xcode15报错: SDK does not contain ‘libarclite‘
iOS Xcode 升级Xcode15报错: SDK does not contain libarclite 一、仔细查看报错代码: SDK does not contain libarclite at the path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ lib/arc/libarclite_iphonesimulator.a; try in…...
python高级练习题库实验2(B)部分
文章目录 题目1代码实验结果题目2代码实验结果题目总结题目1 注册课程小游戏程序 研究下面的例子,并编写一个与这些例子完全相同的程序。使用for loop和break来解决问题。提示用户输入课程数量,是否选择,并且课程代码,最后还需显示已经完成的课程注册数量或者未完成的注册…...
vue项目编译非常慢,经常卡在某个百分点
1、注册插件 2、在项目根目录下的 babel.config.js 文件中加入下方配置 3、将import导入方式改为require导入方式,返回promise 4、如果动态加载组件import引入组件找不到组件(Error: Cannot find module) 使用 webpack 的 require.ensure() …...
开源知识库zyplayer-doc部署指南
1.前置条件 docker已经安装 mysql已经安装且数据库zyplayer-doc存在 服务器ip:192.168.168.99/ 数据库账户:root,密码:123456 2.拉取镜像 docker pull zyplayer/zyplayer-doc:latest 3.启动 docker run -d \--restart unless-stopped \--name zyplayer-doc \-p 8083:8083 …...
第90讲:MySQL数据库主从复制集群原理概念以及搭建流程
文章目录 1.MySQL主从复制集群的核心概念1.1.什么是主从复制集群1.2.主从复制集群中的专业术语1.3.主从复制集群工作原理1.4.主从复制中的小细节1.5.搭建主从复制集群的前提条件1.6.MySQL主从复制集群的架构信息 2.搭建MySQL多实例环境2.1.在mysql-1中搭建身为主库的MySQL实例2…...
PHP反序列化漏洞-魔术方法绕过
一、__wakeup()魔法函数绕过: 在PHP中,__wakeup()是一个魔术方法,用于在反序列化对象时自动调用。当反序列化字符串中的对象属性个数大于实际属性个数时,可以利用这个漏洞进行绕过。 触发条件: PHP版本为5.6.25或早期版本,或者PHP7版本小于7.0.10。反序列化字符串中的对…...
抖店和商品橱窗的区别?这两个千万别再搞混了!
我是电商珠珠 很多人都会将抖店和商品橱窗搞混,想开抖店的人开了商品橱窗,想开橱窗的人开通了抖店。 我做抖店三年了,这种情况屡见不鲜。 那么抖店和商品橱窗究竟有什么区别呢? 1、属性不同 商品橱窗是抖音所展现商品的一个功…...
个人总结钉钉7.5新品发布会
钉钉发布了 7.5 版本,最主要推出了围绕AI能力的各项升级,通过AI“超级助理”提升组织内部的沟通协作效率、管理决策智能化程度,以及相关的音视频、在线文档、Teambition功能的升级,以满足不同企业的多元化需求。截至发布会&#x…...
连接超时的问题
连接超时的问题 通用第三方工具连接超时 connect timeout 方案一: /etc/ssh/sshd_config node1上操作,图是错的 方案二: windows上Hosts文件域名解析有问题 比如: 192.168.xx.100 node1 192.168.xx.161 node1 两个都解析成node…...
python贪吃蛇游戏
为了实现这个游戏,需要用到Python的pygame模块,它是一个专门用于开发游戏的模块,提供了很多方便的功能,比如窗口、图形、音效、事件处理等。 用pygame来创建一个窗口,设置游戏的背景色,画出蛇和食物&#…...
2026年同步网盘哪个好?10款支持本地文件夹自动同步与实时备份工具盘点
在 2026 年,数据即资产。传统“手动上传”已难以满足高频办公:文件一多就容易漏传、版本混乱、协作效率下降。本地文件夹自动同步(落盘即上云)正在成为衡量网盘生产力的核心指标——既能防止硬盘故障导致的数据丢失,也…...
上海AI实验室发布WildClawBench:AI智能体究竟能走多远?
这项由上海人工智能实验室联合香港中文大学、复旦大学、中国科学技术大学、上海交通大学、清华大学、浙江大学及南洋理工大学等多所顶尖机构共同完成的研究,于2026年5月11日以预印本形式发布,论文编号为arXiv:2605.10912v1。感兴趣的读者可通过该编号在a…...
Python核心基础
本文摘要:Python核心基础章节系统讲解了编程基础知识,主要包括:1.字面量的概念与写法,强调字符串必须使用引号包裹;2.变量与常量的定义与使用,介绍命名规则和三种命名风格;3.注释的两种形式&…...
LLaMA论文里没细说的三个‘炼丹’细节:RMSNorm、SwiGLU和RoPE到底怎么用?
LLaMA论文里没细说的三个‘炼丹’细节:RMSNorm、SwiGLU和RoPE到底怎么用? 在构建现代大型语言模型时,论文往往聚焦于宏观架构和性能对比,而将关键实现细节留给读者自行揣摩。LLaMA论文中提到的RMSNorm、SwiGLU和RoPE三项改进&…...
如何在5分钟内掌握ToolsFx密码学工具箱:新手完全指南
如何在5分钟内掌握ToolsFx密码学工具箱:新手完全指南 【免费下载链接】ToolsFx 跨平台密码学工具箱。包含编解码,编码转换,加解密, 哈希,MAC,签名,大数运算,压缩,二维码功…...
如何快速在Windows上安装安卓应用?APK Installer的终极免费解决方案
如何快速在Windows上安装安卓应用?APK Installer的终极免费解决方案 【免费下载链接】APK-Installer An Android Application Installer for Windows 项目地址: https://gitcode.com/GitHub_Trending/ap/APK-Installer 你是否曾想在Windows电脑上运行安卓应用…...
良心云用户如何快速接入Taotoken实现大模型API调用
🚀 告别海外账号与网络限制!稳定直连全球优质大模型,限时半价接入中。 👉 点击领取海量免费额度 良心云用户如何快速接入Taotoken实现大模型API调用 对于在良心云服务器上部署应用的开发者而言,将大模型能力集成到自己…...
暗黑破坏神2存档修改器终极指南:告别重复刷装备,5分钟打造完美角色!
暗黑破坏神2存档修改器终极指南:告别重复刷装备,5分钟打造完美角色! 【免费下载链接】diablo_edit Diablo II Character editor. 项目地址: https://gitcode.com/gh_mirrors/di/diablo_edit 你是否厌倦了在暗黑破坏神2中反复刷装备&am…...
StreamCap:打破直播录制壁垒,轻松捕获40+平台精彩内容
StreamCap:打破直播录制壁垒,轻松捕获40平台精彩内容 【免费下载链接】StreamCap Multi-Platform Live Stream Automatic Recording Tool | 多平台直播流自动录制客户端 基于FFmpeg 支持监控/定时/转码 项目地址: https://gitcode.com/gh_mirrors/st…...
AIDD入门第七课:大语言模型是如何读懂文字,又如何走进药物发现的?
前几篇文章中,我们已经介绍了机器学习、深度学习、神经网络,以及CNN、RNN、Transformer等经典结构。今天这篇文章,进入一个更靠近当下AI浪潮的主题:大语言模型与自然语言处理。自然语言处理(Natural Language Processi…...
