文件路径配置
This commit is contained in:
parent
c494111a4e
commit
073b63682b
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.system.config;
|
||||
|
||||
|
||||
import com.bonus.system.file.util.SystemUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
/**
|
||||
* 外部文件访问
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String filePath= SystemUtils.getUploadPath();
|
||||
/** 本地文件上传路径 */
|
||||
registry.addResourceHandler("/statics/**")
|
||||
.addResourceLocations("file:" + filePath+"/");
|
||||
registry.addResourceHandler("/files/**")
|
||||
.addResourceLocations("file:"+filePath);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue