SpringBoot favicon Chrome设置问题解决方案
2020-03-11 17:51
585 查看
今天学习SpringBoot 设置favicon,使用springboot 2.2.4 版本。浏览器为Chrome,根据文档设置无法实现显示。但是如果更换为Safiri浏览器,可以正确显示,现把Chrome的解决方法写下来
其他资料显示,把favicon.ico 图片文件 Copy 到 默认到资源文件夹即可,包括,SpringBoot定义的文件为:
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/","classpath:/resources/", "classpath:/static/", "classpath:/public/" };
我先把图片放到默认根目录下,但是怎么显示都无法显示出来,并且用<img src="/favicon.ico"> 也无法加载,通过地址也无法在页面显示。
所以,把该图片放到以上资源文件夹的images 下,此时可以在页面中显示图片,通过浏览器地址也可以访问到图片。
但是浏览器标签页面 还是不显示小图片,在 <head> 标签增加
<link rel="shortcut icon" href="images/favicon.ico" rel="external nofollow" rel="external nofollow" />
成功显示
全代码为:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="shortcut icon" href="images/favicon.ico" rel="external nofollow" rel="external nofollow" /> </head> <body> <img src="/asserts/favicon.ico"> <img src="/images/favicon.ico"> <h4>欢迎首页rrr -- res</h4> </body> </html>
其实和基本的网页显示ICO图标是一样的,大家可以在本地测试下,感谢大家的学习和对脚本之家的支持。
相关文章推荐
- vue+springboot前后端分离工程跨域问题解决方案解析
- Springboot @Value获取值为空问题解决方案
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
- Spring boot @@Autowired注入空指针问题解决方案
- springboot中使用redis,key序列化问题解决方案
- springboot,feign上传超大文件,超时等问题解决方案
- SpringBoot项目设置断点debug调试无效忽略web.xml问题的解决
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案 标签: spring 201
- 通过spring boot 设置tomcat解决 post参数限制问题
- 关于spring boot无法自动注入bean问题解决方案
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
- 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案
- shiro+spring boot+mybatis启动循环引用问题解决思路和方案
- 后端(springboot)解决跨域问题
- jquery乱码与contentType属性设置问题解决方案
- intellij idea2016 linux springboot项目下解决热部署问题
- Spring boot 项目 maven的profile多环境配置 不自动替换变量的问题解决
- SpringBoot项目使用视图解析器解决Circular view path 问题
- 使用spring3.0的cache方案解决缓存问题
- 解决spring设置filter过滤器结合rest风格获取post请求body参数输入流问题