一、SpringBoot 自定义项目启动欢迎页
已经分析过SpringBoot 的资源访问路径:一篇文章带你从源码解析 SpringBoot 中的静态资源存放位置
所以对于欢迎页 index.html 可以存放,查找顺序是先从 static 目录下查找,没有再从 templates 目录下查找:这里不需要加Controller 控制,这是 SpringBoot 默认的配置从 index 查找
此时将 static 目录下的 index.html 删除:再次访问
注意,要想 templates 目录生效,需要加入 thymeleaf 依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、SpringBoot 自定义 favicon
存在问题
所谓的 favicon 指的就是,这样的图标:
推荐制作favicon网址:https://tool.lu/favicon/
上传图片,裁定区域,这里下载 32x32 大小的 ICO
对于下载下来的图标,有两个存放位置:静态资源路径下,或者类路径下,静态资源路径的优先级高于类路径的优先级:static 的优先级高于 resources
这里就一个所以直接放置即可,注意命名为 favicon
访问测试:
https://www.cnblogs.com/nosouln/p/12624192.html