当前位置: 主页 > 前端开发

web前端文件目录结构-web前端文件vendor目录

发布时间:2023-03-12 11:05   浏览次数:次   作者:佚名

承接我们上一节的示例代码,首先看下示例上节示例项目的目录结构

这里写图片描述

By default, Spring Boot serves static content from a directory called /static 
(or /public or /resources or /META-INF/resources) in the classpath or from the 
root of the ServletContext.
 这里说的是   默认情况下,Spring Boot 的静态文件加载顺序是  
  META/resources > resources > static > public  里面找是否存在相应的资源,
  如果有则直接返回。

接下来web前端文件目录结构,我们用代码做一下测试web前端文件目录结构,验证 Spring Boot 静态文件加载顺序

在 src/main/resources 目录下创建 public, static,templates 文件夹

这里写图片描述

新建静态文件 index.html, 示例代码如下:(在三个目录下分别创建,alert 查看 打印的单词信息)




    
    Title
    
    
    




启动程序, 访问 :8080/index.html

这里写图片描述

这里写图片描述

我们看到首先 打印的 是 static,删除 static 目录 重新启动 打印出了 public

这样就 我们就简单的验证了静态文件的加载顺序。。。