一:添加类
package com.gllic.workweixin.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @program: workweixin
* @ClassName URLConfig
* @description:
* @author: Marlo
* @create: 2021-06-17 18:29
* @Version 1.0
**/
@Configuration
public class URLConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/img/**").addResourceLocations("file:/C:/myselefzxq/image/");
}
}
二、修改图片引用地址
<img src="./img/tx.jpg">
springboot项目Not allowed to load local resource: html中引用本地图片
原文:https://www.cnblogs.com/Marlo/p/14896836.html