mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
21 lines
831 B
Java
21 lines
831 B
Java
package cn.hellohao.config;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
|
import java.io.File;
|
|
|
|
@Configuration
|
|
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
|
|
|
|
@Override
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
String filePath =File.separator + "HellohaoData" + File.separator;
|
|
System.out.println(filePath);
|
|
//其中OTA表示访问的前缀。"file:D:/OTA/"是文件真实的存储路径
|
|
//registry.addResourceHandler("/test/**").addResourceLocations("file:C:/test/");
|
|
registry.addResourceHandler("/links/**").addResourceLocations("file:"+filePath);
|
|
}
|
|
}
|