懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
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 }