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来创建一个窗口,设置游戏的背景色,画出蛇和食物&#…...
OpenClaw排错指南:Qwen3-VL:30B部署常见问题与解决方案
OpenClaw排错指南:Qwen3-VL:30B部署常见问题与解决方案 1. 问题背景与排查准备 上周我在本地部署Qwen3-VL:30B模型并接入OpenClaw时,遇到了不少"坑"。这个号称最强的多模态大模型确实强大,但在私有化部署过程中,从模型…...
SDMatte在内容制作中的应用:短视频封面透明底素材、PPT动态图源快速生成
SDMatte在内容制作中的应用:短视频封面透明底素材、PPT动态图源快速生成 1. 为什么你需要专业的AI抠图工具 在内容创作领域,时间就是金钱。无论是制作短视频封面,还是设计PPT演示文稿,抠图都是最耗时的环节之一。传统Photoshop抠…...
Struts2拦截器实战:从零构建权限控制与日志记录
1. Struts2拦截器机制解析 Struts2拦截器是框架最核心的机制之一,它采用AOP(面向切面编程)思想,在Action执行前后插入自定义逻辑。想象一下拦截器就像地铁安检系统:每个乘客(请求)都必须经过安检…...
Kafka连接报错?手把手教你解决localhost:9092不可用问题(附真实案例)
Kafka连接报错?手把手教你解决localhost:9092不可用问题(附真实案例) 当你第一次尝试在本地环境运行Kafka生产者时,看到"Connection to node -1 (localhost/127.0.0.1:9092) could not be established"这样的报错信息&a…...
Windows下OpenClaw实战:30分钟接入Qwen3.5-4B-Claude模型
Windows下OpenClaw实战:30分钟接入Qwen3.5-4B-Claude模型 1. 为什么选择WindowsOpenClaw组合 去年我在尝试自动化办公流程时,发现很多AI工具对Windows支持并不友好。直到遇到OpenClaw,这个开源的智能体框架让我眼前一亮——它不仅能像人类一…...
工厂里EtherCAT从站模块坏了别慌!手把手教你用Startup list和CoE-online快速换新(附配置顺序避坑指南)
工厂EtherCAT从站模块更换实战指南:Startup list与CoE-online的高效应用 当生产线上的EtherCAT从站模块突然罢工,设备维护工程师往往面临两难选择:是临时在线修改参数快速恢复生产,还是彻底解决"即插即用"的配置难题&am…...
OpenClaw远程控制方案:通过nanobot实现安全外网访问
OpenClaw远程控制方案:通过nanobot实现安全外网访问 1. 为什么需要远程控制OpenClaw? 上周我需要出差三天,但电脑上运行的OpenClaw自动化任务突然报错。当时我面临两个选择:要么让任务中断三天,要么冒险把本地网关直…...
Python AI 用例工具部署踩坑实录:Docker镜像体积暴增300%、GPU显存泄漏、模型热加载失败的5个根因与秒级修复方案
第一章:Python AI 用例工具部署的典型失败图谱在真实生产环境中,Python AI 工具链(如 LangChain、LlamaIndex、FastAPI 封装的推理服务)的部署失败往往并非源于模型能力缺陷,而是由基础设施、依赖冲突与配置漂移引发的…...
终极桌面歌词解决方案:LyricsX 让你的音乐体验全面升级
终极桌面歌词解决方案:LyricsX 让你的音乐体验全面升级 【免费下载链接】Lyrics Swift-based iTunes plug-in to display lyrics on the desktop. 项目地址: https://gitcode.com/gh_mirrors/lyr/Lyrics 在macOS平台上享受音乐时,你是否曾渴望拥有…...
通义千问3-Reranker-0.6B性能调优:提升推理速度的3种方法
通义千问3-Reranker-0.6B性能调优:提升推理速度的3种方法 1. 引言 如果你正在使用通义千问3-Reranker-0.6B模型,可能会遇到推理速度不够理想的情况。特别是在处理大量文本排序任务时,等待时间可能会影响整体工作效率。 其实,这…...
