1.Springboot默认显示的是一片叶子,关闭默认图标
spring:
favicon:
enabled: false
#spring:
# mvc:
# favicon:
# enabled: false
2.将favicon.ico(文件名不能变动)放到static
目录,尽量放在资源路径下
例如:static/ public/ resources/
3. 在页面的head标签添加代码
<head>
<link rel="shortcut icon" th:href="@{/favicon.ico}"/>
<link rel="bookmark" th:href="@{/favicon.ico}"/>
</head>
如果不是thymeleaf这样添加
<head>
<link rel="shortcut icon" href="/favicon.ico"/>
<link rel="bookmark" href="/favicon.ico"/>
</head>
来源:CSDN
作者:菜鸟bai
链接:https://blog.csdn.net/bai1964847519/article/details/104679827