【JavaWeb】Tomcat_WebAPP的标准结构

在webapps目录下创建app目录

app目录下创建aaa.html

app目录下创建static目录,在static目录下创建如下三个目录


WEB-INF目录下的资源是受保护的资源,是不可以通过浏览器直接访问的资源

在app目录下创建WEB-INF目录

将图片放入该目录下,并在浏览器中访问,发现无法访问

将图片放在其他目录下,是可以访问的

在该目录下创建如下内容

web.xml文件内容如下:

css 复制代码
<?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="https://jakarta.ee/xml/ns/jakartaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
                      https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
  version="6.0"
  metadata-complete="true">

</web-app>

总结

一个可以部署到tomcat/webapps中的,标准的app目录结构如下

或者

相关推荐
名字还没想好☜10 分钟前
Spring Boot 优雅停机实战:等在途请求处理完再退出,配合 K8s preStop 别丢请求
java·后端·spring
摇滚侠15 分钟前
《Spring Boot 3:高级与架构设计》第 1 章 Bean 与 BeanDefinition 个人理解 2
java·spring boot·笔记·后端
qq_2695067517 分钟前
第30课-请求与响应
java
qq_2695067531 分钟前
第28课-AJAX与前端框架
java
程序员清风31 分钟前
Java 后端如何接入大语言模型
java·spring boot·架构·aigc
xieliyu.35 分钟前
JVM 垃圾回收机制详解:从标记过程、回收算法到垃圾收集器
java·jvm·笔记·java-ee
JavacKaka38 分钟前
Redis大Key导致生产事故复盘博客-2026-09-18
java
右耳朵猫AI1 小时前
Java周刊2026W38 | Micronaut 修补三漏洞、JDK 27 提速 54%、Jetty 修复抖动测试
java·后端·spring
事已至此先睡覺吧1 小时前
第二篇:Java 基础语法:变量、数据类型、运算符与类型转换
java
Wang's Blog1 小时前
Java 项目实战: 外卖平台-后台退出功能与首页iframe架构
java·服务器·redis