Update ResourceConfigAdapter.java

cyj
pbvfus8to 8 months ago
parent 66d3a34972
commit 246e6d4ea9

@ -7,16 +7,31 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/** /**
*
* `WebMvcConfigurer`Spring MVC访
* 使URL访便
*
* @author TRACK * @author TRACK
*/ */
@Configuration @Configuration
// 使用 @Configuration 注解声明该类是一个配置类Spring会自动扫描并加载该类中的配置信息用于对Spring容器进行相关配置
public class ResourceConfigAdapter implements WebMvcConfigurer { public class ResourceConfigAdapter implements WebMvcConfigurer {
@Autowired @Autowired
// 通过依赖注入获取ImgUploadUtil工具类对象该工具类可能用于获取图片上传的路径等相关信息
private ImgUploadUtil imgUploadUtil; private ImgUploadUtil imgUploadUtil;
/**
*
* `ResourceHandlerRegistry`访
* `/mall4j/img/`URL`ImgUploadUtil`
* URLSpring MVC
*
* @param registry 访
*/
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/mall4j/img/**").addResourceLocations("file:" + imgUploadUtil.getUploadPath()); registry.addResourceHandler("/mall4j/img/**")
.addResourceLocations("file:" + imgUploadUtil.getUploadPath());
} }
} }
Loading…
Cancel
Save