最新版宁夏武警公众号项目后端
This commit is contained in:
30
src/main/java/com/guahao/UploadConfig.java
Normal file
30
src/main/java/com/guahao/UploadConfig.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.guahao;
|
||||
|
||||
/**
|
||||
* @ClassName: UploadConfig
|
||||
* @Description:
|
||||
* @Author T.W
|
||||
* @Date 2021/10/12
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
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 UploadConfig implements WebMvcConfigurer {
|
||||
@Value("${file.staticAccessPath}")
|
||||
private String staticAccessPath;
|
||||
|
||||
@Value("${file.uploadFolder}")
|
||||
private String uploadFolder;
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + uploadFolder);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user