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

或者

相关推荐
糖果店的幽灵3 分钟前
langgraph分支之 - 动态分支(Dynamic Branch)
java·前端·javascript·人工智能·langgraph
唐青枫1 小时前
Java Spring Security 实战详解:从登录认证到 JWT 权限控制
java
曹牧1 小时前
文档格式:OFD
java
豆角焖肉1 小时前
Maven进阶与搭建私服
java·maven
大不点wow1 小时前
Java序列化与反序列化:让对象走出JVM
java·开发语言·jvm
噢,我明白了2 小时前
Java中日期和字符串的处理
java·开发语言·日期
dkbnull2 小时前
Spring Boot请求处理组件对比详解
java·spring boot
jun_bai2 小时前
Orthanc服务器使用java上传dicom影像文件
java·运维·服务器
顺风尿一寸2 小时前
记一次 Spring AOP 与定时任务引发的死锁排查
java
用户446139430272 小时前
从单体到微服务:我们项目的拆分思路和踩坑记录
java