yantian yue
2023-10-20 a7c91f14d9a671a5ad1def32e2a88d4938ecba33
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.config;
2
3 import org.springframework.context.annotation.Configuration;
4 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
5 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
6
7 @Configuration
8 public class MyConfiguration extends WebMvcConfigurerAdapter {
9
10     @Override
11     public void addResourceHandlers(ResourceHandlerRegistry registry){
12
13         registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
14         //addResourceHandler是指定的虚拟路径,addResourceLocations是自己的物理路径,
15         registry.addResourceHandler("/file/**").addResourceLocations("file:D:/");
16         super.addResourceHandlers(registry);
17     }
18 }