若在项目中加入了以下代码:
server.servlet.context-path=/xxx
则需要在每一个html中加入
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
我猜测应该是Spring Boot自动访问localhost:端口/favicon.ico后加项目名称后导致还是默认访问localhost:端口/favicon.ico而不是localhost:端口/项目名/favicon.ico,使得访问图标404
**注意:**若上述方法为解决问题,请使用Ctrl+F5强制刷新页面,或者Ctrl+Shift+Delete清除缓存!!!