【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目录结构如下

或者

相关推荐
杂货铺的小掌柜11 分钟前
MAC版IDEA常用快捷键
java·macos·intellij-idea
xjz184223 分钟前
JVM虚拟线程:JEP 444开启Java并发编程新纪元
java
JH307323 分钟前
Spring Retry 实战:优雅搞定重试需求
java·后端·spring
蓝眸少年CY38 分钟前
测试Java性能
java·开发语言·python
何包蛋H38 分钟前
数据结构深度解析:Java Map 家族完全指南
java·开发语言·数据结构
linsa_pursuer1 小时前
最长连续序列
java·数据结构·算法·leetcode
强子感冒了1 小时前
Java集合框架深度学习:从Iterable到ArrayList的完整继承体系
java·笔记·学习
drebander1 小时前
Cursor IDE 中 Java 项目无法跳转到方法定义问题解决方案
java·ide·cursor
来不及辣哎呀1 小时前
学习Java第六十二天——Hot 100-09-438. 找到字符串中所有字母异位词
java·开发语言·学习
linsa_pursuer1 小时前
移动零算法
java·算法