锋哥原创的Springboot+Layui python222网站实战:
application-dev.yml里面配置icon本地图片位置
systemImagesFilePath: D:\\systemImages\\
(如果是linux服务器上:)路径类似:
systemImagesFilePath: /home/systemImages/
新建config包,新建WebAppConfigurer类
package com.python222.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 拦截配置--调用链
* @author java1234_小锋
* @site www.java1234.com
* @company Java知识分享网
* @create 2019-08-13 下午 12:26
*/
@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {
@Value("${systemImagesFilePath}")
private String systemImagesFilePath;
/**
* 配置虚拟路径映射
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//文件磁盘图片url 映射
//配置server虚拟路径,handler为前台访问的目录,locations为files相对应的本地路径
registry.addResourceHandler("/systemImages/**").addResourceLocations("file:"+systemImagesFilePath); // 系统图片映射
}
}
index.html页面加上:
<link href="/systemImages/favicon.ico" rel="SHORTCUT ICON">
icon有了